5

Is it possible to have a two-edge path, as in the picture below?

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzstyle{status} = [rectangle, draw=black, text centered, anchor=north, text=black, minimum width=2em, minimum height=2em, node distance=6ex and 7em, font=\bfseries]
\tikzstyle{line} = [draw,thick,-latex]
\tikzstyle{transition} = [font=\small]

\begin{tikzpicture}
\node [status, fill=green] (T) {H};
\node [status, fill=red, right=5em of T] (A) {A};
\node [status, fill=gray, right=5em of A] (D) {D};

\path [line] (T) -- (A) node[transition,pos=0.5,above,align=left] {$\#A \geq 1$};
\path [line] (A) -- (D) node[transition,pos=0.5,above,align=left] {wait $\tau$ tick\\$\tau\sim\mathcal{G}(\lambda)$};
%\path [line] (D) -| (T) node[transition,pos=0.83,left] {$p_{repl}$};
\end{tikzpicture}

\end{document}

screenshot

How I would like it:

mockup

Ricardo Cruz
  • 1,770
  • 1
  • 22
  • 34

1 Answers1

8

You can use something like:

\path [line] (D) -- ++(0,-30pt) -| (T) node[transition,pos=0.83,left] {$p_{repl}$};

enter image description here

The complete code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzstyle{status} = [rectangle, draw=black, text centered, anchor=north, text=black, minimum width=2em, minimum height=2em, node distance=6ex and 7em, font=\bfseries]
\tikzstyle{line} = [draw,thick,-latex]
\tikzstyle{transition} = [font=\small]

\begin{tikzpicture}
\node [status, fill=green] (T) {H};
\node [status, fill=red, right=5em of T] (A) {A};
\node [status, fill=gray, right=5em of A] (D) {D};

\path [line] (T) -- (A) node[transition,pos=0.5,above,align=left] {$\#A \geq 1$};
\path [line] (A) -- (D) node[transition,pos=0.5,above,align=left] {wait $\tau$ tick\\$\tau\sim\mathcal{G}(\lambda)$};

\path [line] (D) -- ++(0,-30pt) -| (T) node[transition,pos=0.83,left] {$p_{repl}$};
\end{tikzpicture}

\end{document}
Gonzalo Medina
  • 505,128
  • I was just about to reply to my own question, because I remembered meanwhile of adding a \coordinate below one node and do \draw (D.south) -| (mid) -| (T). But yours even nice, thank you! – Ricardo Cruz Jun 25 '15 at 17:56