Latex: How to draw a transaction

Submitted by admin on Fri, 06/13/2014 - 13:03

<code>

\begin{tikzpicture}
[inner sep=2mm,auto,bend left,
place/.style={circle,draw=blue!50,fill=blue!20,thick},
transition/.style={rectangle,draw=black!50,fill=black!20,thick}]

\node[place] (one) {};
\node[place] (two) [right=of one] {};
\node[place] (three) [right=of two] {};
\node[place] (four) [right=of three] {};
\node[place] (five) [right=of four] {};
\node[place] (six) [right=of five] {};
\node[place] (seven) [right=of six] {};

\draw [->] (one) to node {Add} node [swap] {} (two);
\draw [->] (two) to node {Retract} node [swap] {} (three);
\draw [->] (three) to node {Add} node [swap] {} (four);
\draw [->] (four) to node {Retract} node [swap] {} (five);
\draw [->] (five) to node {Add} node [swap] {} (six);
\draw [->] (six) to node {Retract} node [swap] {} (seven);

\draw (-0.4,-0.8) rectangle (0.4,1);

\draw (9.15,-0.8) rectangle (9.95,1);

\draw [->, bend right] (one) to node {Transaction} node [swap] {} (seven);

\draw (0, 1.2) node {State 1};
\draw (9.5, 1.2) node {State 2};

\end{tikzpicture}

</code>

Etiquetas
Imagen