I have the following three automaton :
I want to put them in boxes and add some link, such that I can get something like this:
Here is my code :
\documentclass{standalone}
\usepackage{etex}
\usepackage[version=0.96]{pgf}
\usepackage{tikz}
\usetikzlibrary{calc,arrows,shapes,snakes,automata,backgrounds,petri}
\begin{document}
\begin{tikzpicture}[->,node distance=1.3cm,>=stealth',bend angle=20,auto]
\tikzstyle{place}=[circle,thick,draw=blue!75,fill=blue!20,minimum size=10mm]
\tikzstyle{red place}=[place,draw=red!75,fill=red!20]
\tikzstyle{every label}=[red]
\begin{scope}[local bounding box=scope1,every node/.style={scale=.4}]
% First net
\node [initial, place] (l0) {$l0$};
\node [place] (l1) [xshift=2cm,yshift=-4cm]{$l1$};
\node [place] (l2) [xshift=-2cm,yshift=-4cm]{$l2$};
\path (l0) edge [in=30, out=60,loop] node{$eq0$} (l0)
edge [in=150, out=120,loop] node[above]{$set0$} (l0)
edge [bend left] node{$set1$} (l1)
edge [bend right] node[left]{$set2$} (l2)
(l1) edge [in=60, out=30,loop] node[above]{$set1$} (l1)
edge [in=-60, out=-30,loop] node[below]{$eq1$} (l1)
edge [bend left] node[right]{$set0$} (l0)
edge [bend right] node[above]{$set2$} (l2)
(l2) edge [in=120, out=150,loop] node[above]{$set2$} (l2)
edge [in=240, out=210,loop] node[below]{$eq2$} (l2)
edge [bend right] node[left]{$set0$} (l0)
edge [bend right] node[below]{$set1$} (l1);
\end{scope}
\begin{scope}[shift={($(scope1.east)+(3cm,0)$)},every node/.style={scale=.4}]
% First net
\node [initial, place] (l1) {idle};
\node [place] (l2) [right of=l1,xshift=3cm,label=above:$x\le k$]{req};
\node [place] (l3) [below of=l2,yshift=-3cm] {wait};
\node [place] (l4) [left of=l3,xshift=-3cm] {cs};
\path (l1) edge node[align=center, pos=0.5]{$try\quad reset\{x\}$ } (l2)
(l2) edge node[align=center, pos=0.5, swap]{$set$ \\ $reset\{x\}$} (l3)
(l3) edge node[align=center, pos=0.5]{$enter\quad x > k$} (l4)
edge [bend right] node[align=center, pos=0.5, swap]{$retry$ \\ $reset\{x\}$} (l2)
(l4) edge node[align=center,pos=0.5]{$exit$} (l1);
\end{scope}
\begin{scope}[shift={($(scope1.west)+(-3cm,0)$)},every node/.style={scale=.4}]
% First net
\node [initial, place] (l1) {idle};
\node [place] (l2) [right of=l1,xshift=3cm,label=above:$x\le k$]{req};
\node [place] (l3) [below of=l2,yshift=-3cm] {wait};
\node [place] (l4) [left of=l3,xshift=-3cm] {cs};
\path (l1) edge node[align=center, pos=0.5]{$try\quad reset\{x\}$ } (l2)
(l2) edge node[align=center, pos=0.5, swap]{$set$ \\ $reset\{x\}$} (l3)
(l3) edge node[align=center, pos=0.5]{$enter\quad x > k$} (l4)
edge [bend right] node[align=center, pos=0.5, swap]{$retry$ \\ $reset\{x\}$} (l2)
(l4) edge node[align=center,pos=0.5]{$exit$} (l1);
\end{scope}
\begin{pgfonlayer}{background}
\filldraw [line width=4mm,join=round,black!10]
([yshift=0.5cm]l3 -| l3.east) rectangle (l4.south -| l1.west);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
I am trying to put these automaton in rectangles and to align them but I could not figure out an efficient way to do it. Any helps would be great.
Many thanks

initial) etc.) – Torbjørn T. Jun 29 '15 at 12:56\usepackagecan only be used in the preamble. To make it into a proper minimal working example, you only would have needed to add a documentclass anddocumentenvironment, as I did in my edit. It's theautomatalibrary that defines theinitialstyle, and if you're not familiar with it, it's a bit hard to guess. – Torbjørn T. Jun 29 '15 at 13:40