LaTeX

TikZ : FSM

ForceCore 2010. 8. 28. 21:51


Code:
\tikzstyle{state} = [draw,circle split,node distance=2.5cm,
minimum height=2em]
\begin{tikzpicture}[node distance = 3cm, auto]
% Place nodes
\node (reset) {reset};
\node [state, below of=reset] (init) {000 \nodepart{lower} G/R};
\node [state, below of=init] (wait) {001 \nodepart{lower} G/R};
\node [state, below of=wait] (hrdy) {010 \nodepart{lower} Y/R};
\node [state, below of=hrdy] (hleft) {011 \nodepart{lower} L/R};
\node [state, below left of=hleft] (frdy) {100 \nodepart{lower} Y/R};
\node [state, below of=frdy] (fleft) {101 \nodepart{lower} R/L};
\node [state, below of=fleft] (last) {110 \nodepart{lower} R/Y};
\node [state, below right of=hleft] (nofleft) {111 \nodepart{lower} Y/R};

% two dummy nodes for centering.
\node at ([xshift=5cm, yshift=-9cm] init) {};
\node at ([xshift=-5cm,yshift=-9cm] init) {};

% Draw edges
\begin{scope}[>=latex]
\path[->] (reset)  edge   (init);

\path[->] (init)   edge node [left] {H+L}   (wait);
\path[->] (init)   edge [in=30,out=60,loop] node {H'\&L'} ();

\path[->] (wait)   edge node [left] {H}   (hrdy);
\path[->] (wait)   edge [out=230,in=100] node [left] {H'}   (frdy);

\path[->] (hrdy)   edge   (hleft);

\path[->] (hleft)  edge node [below right] {L}   (frdy);
\path[->] (hleft)  edge node [below left] {L'}   (nofleft);

\path[->] (nofleft)  edge [out=60,in=330]   (init);
\path[->] (nofleft)  edge [out=60,in=330]   (init);

\path[->] (frdy)  edge   (fleft);
\path[->] (fleft)  edge   (last);
\path[->] (last)  edge [out=140,in=220]   (init);
\end{scope}
\end{tikzpicture}

ㅋㅋ
edge out, in을 주의할 것.