Tikz: two edge paths
Can I use \ path to draw a line through 2 edges.
Consider:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\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{document}
\begin{tikzpicture}
\node [status, fill=green] (T) {H};
\node [status, fill=red, right=4em of T] (A) {A};
\node [status, fill=gray, right=4em 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:
Layout of what I want:
+3
source to share
1 answer
Easier than we thought, you can force it to substitute the commented line (line 17) in your code with:
\path [line] (D) -- ++(0,-1) -- +(-4.25,0) -- (T) node[transition,pos=0.3,right] {$p_{repl}$};
Output:
Improvement: Better yet, using -|
and then one aux point instead of two (one required):
\path [line] (D) -- ++(0,-1) -| (T) node [transition,pos=0.8,left] {$p_{repl}$};
+2
source to share