2015-06-25 108 views
3

我可以使用\ path繪製一條經過兩條邊的線。Tikz:兩個邊緣路徑

考慮:

\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

樣機的我想要的東西:

mockup

+0

剛注意到我重複了,對不起! http://tex.stackexchange.com/questions/252241/tikz-two-edges-path-connection –

回答

2

比我們想象的要簡單,你可以把它替換評論線(李

\path [line] (D) -- ++(0,-1) -- +(-4.25,0) -- (T) node[transition,pos=0.3,right] {$p_{repl}$}; 

輸出:在你的代碼NE 17號)

screenshot of the output pdf

改進:甚至更​​好,使用-|然後一個輔助點只,而不是兩個(一個需要):

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