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

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}
  • 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
  • @RicardoCruz You're welcome! – Gonzalo Medina Jun 25 '15 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.