I would like to add a background behind some nodes of an automaton but the background needs to refer to the nodes of the automaton. So I don't know how to draw it "before" drawing the automaton since I need to refer to the nodes identifiers.
\documentclass[margin=5mm]{standalone}
\usepackage{tikz} \usetikzlibrary{arrows,automata,calc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=20mm,semithick,
information text/.style={rounded corners=1pt,inner sep=1ex},font=\scriptsize]
\begin{scope}
\node[initial,initial where=left,initial text=,initial distance=4mm,
accepting,state,draw=black,fill=orange!15] (s) {$s_0$};
\node[accepting,state,draw=black,fill=yellow!4] (t)[right of=s] {$t_0$};
\node[state,draw=black,fill=yellow!4] (s1)[below of=s] {$s_1$};
\node[accepting,state,draw=black,fill=orange!15] (t1)[right of=s1] {$t_1$};
\path (s) edge[bend angle=25,bend left] node {$a$} (t)
(t) edge node[below=2pt] {$b$} (s)
(s1) edge[bend angle=25,bend left] node {$a$} (t1)
(t1) edge node[below=2pt] {$b$} (s1)
(s) edge[densely dashed] node[left=2pt] {$c$} (s1)
(t) edge[densely dashed] node[right=2pt] {$d$} (t1);
\filldraw[fill=cyan!20,draw=cyan!20,rounded corners=5pt] ($(s.north)+(0,0.25)$) -- ($(s.west)+(-0.25,0)$) -- ($(t1.south)+(0,-0.25)$)-- ($(t1.east)+(0.25,0)$) -- ($(t.east)+(0.25,0)$) -- ($(t.north)+(0,0.25)$) node {};
\end{scope}
\end{tikzpicture}
\end{document}



backgroundlibrary. – Oct 05 '16 at 09:22