chap1-anim.tex 3.03 KB
\documentclass[multi={tikzpicture},crop=true,border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,arrows.meta,petri}
\tikzset{
  >=latex,
  every place/.style={minimum size=6mm},
  every transition/.style={minimum size=6mm},
  token distance=6pt,
}

\tikzstyle{trans}=[transition]

\tikzstyle{state}=[draw=blue!50!gray!50!white,
  fill=blue!70!gray!10!white,
  line width=2pt,
  cloud,cloud puffs=8,
  inner sep=-1pt]

\tikzstyle{fire}=[arrows={-Straight Barb[scale=.6]},
  shorten >=-2pt, shorten <=-1pt,
  draw=blue!50!gray!50!white,
  line width=2pt,
  fill opacity=0,
  text opacity=1,
  line cap=round,
  rounded corners]

\tikzstyle{active}=[draw=green!50!gray!50!white,
  fill=green!70!gray!10!white]

\def\matrix #1#2#3#4{%
  $\begin{array}{c@{\hspace{5pt}}c}
    #1 & #2 \\
    #3 & #4
  \end{array}$}

\begin{document}

%%FRAME

\begin{tikzpicture}
  \begin{scope}[yshift=45mm,xshift=28mm,scale=1.2]
    \node[place,tokens={{ state["a"] }}] (a) at (0,0) {};
    \node[left] at (a.west) {$a$};
    \node[trans,{{ active["t"] }}] (t) at (1,0) {$t$};
    \draw[->] (a) -- node[above]{2} (t);
    \node[place,tokens={{ state["b"] }}] (b) at (2,0) {};
    \node[right] at (b.east) {$b$};
    \draw[->] (t) -- (b);
    \node[trans,{{ active["u"] }}] (u) at (2,-1) {$u$};
    \draw[->] (b) -- (u);
    \node[place,tokens={{ state["c"] }}] (c) at (2,-2) {};
    \node[right] at (c.east) {$c$};
    \draw[->] (u) -- (c);
    \node[trans,{{ active["v"] }}] (v) at (1,-2) {$v$};
    \draw[->] (c) -- (v);
    \node[place,tokens={{ state["d"] }}] (d) at (0,-2) {};
    \node[left] at (d.west) {$d$};
    \draw[->] (v) -- node[above]{2} (d);
    \node[trans,{{ active["w"] }}] (w) at (0,-1) {$w$};
    \draw[->] (d) -- (w);
    \draw[->] (w) -- (a);
  \end{scope}
  \begin{scope}[scale=2]
    \node[state,{{ active[0] }}] (0) at (0,0) {\matrix 3000};
    \node[state,{{ active[1] }}] (1) at (1,0) {\matrix 1100};
    \draw[fire,{{ active[0,1] }}] (0) -- node[above] {$t$} (1);
    \node[state,{{ active[2] }}] (2) at (2,0) {\matrix 1001};
    \draw[fire,{{ active[1,2] }}] (1) -- node[above] {$u$} (2);
    \node[state,{{ active[3] }}] (3) at (3,0) {\matrix 1020};
    \draw[fire,{{ active[2,3] }}] (2) -- node[above] {$v$} (3);
    \node[state,{{ active[4] }}] (4) at (4,0) {\matrix 2010};
    \draw[fire,{{ active[3,4] }}] (3) -- node[above] {$w$} (4);
    \draw[fire,{{ active[4,0] }}] (4) |- node[near end,above] {$w$} +(-1,.5) -| (0);
    \node[state,{{ active[5] }}] (5) at (1,-1) {\matrix 0110};
    \draw[fire,{{ active[4,5] }}] (4) |- node[pos=.05,right] {$t$} +(-1,-1.5) -| (5);
    \draw[fire,{{ active[5,1] }}] (5) -- node[left] {$w$} (1);
    \node[state,{{ active[6] }}] (6) at (2,-1) {\matrix 0011};
    \draw[fire,{{ active[5,6] }}] (5) -- node[above] {$u$} (6);
    \draw[fire,{{ active[6,2] }}] (6) -- node[left] {$w$} (2);
    \node[state,{{ active[7] }}] (7) at (3,-1) {\matrix 0030};
    \draw[fire,{{ active[7,3] }}] (7) -- node[left] {$w$} (3);
    \draw[fire,{{ active[6,7] }}] (6) -- node[above] {$v$} (7);
  \end{scope}
\end{tikzpicture}

%%/FRAME

\end{document}