Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following code:

\begin{document}



\begin{figure}
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 1, transform shape]


\node[initial,state] (A)                                    {$s_0$};
\node[state]         (B) [right of=A]                       {$s_2$};
\node[state]         (C) [above of=B]                       {$s_1$};
\node[state]         (D) [below of=B]                       {$s_3$};

\path[->] (A) edge [left]       node [align=center]  {$ c = c + 1 $} (C)
      (A) edge [above]      node [align=center]  {$ c = c + 5 $} (B)
      (A) edge [left]       node [align=center]  {$ c = c - 1 $} (D)
      (B) edge [right]      node [align=center]  {$ c = c - 1 $} (D)
      (C) edge [loop above] node [align=center]  {$ c = c + 1 $} (C)
      (D) edge [loop below] node [align=center]  {$ c = c - 2 $} (D);

\end{tikzpicture}
\caption{An example of SST}
\end{figure}

\end{document}

I get the following automaton : enter image description here

How can I draw S2 and S4 as final states (double circle)?

share|improve this question
1  
You should also add a preamble to your examples. It is annoying to have to add them manually for test. Beside this, did you try to add the option double to your node? –  Ulrike Fischer Jul 18 '12 at 9:14
add comment

1 Answer

up vote 9 down vote accepted

That could be done by means of the option accepting (see as reference 25 Automata Drawing Library in the pgfmanual version April 25, 2012).

Code (I assumed s_1 and s_3 as final states):

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,arrows}

\begin{document}
\begin{figure}
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 1, transform shape]


\node[initial,state] (A)                                    {$s_0$};
\node[state]         (B) [right of=A]                       {$s_2$};
\node[state,accepting]         (C) [above of=B]                       {$s_1$};
\node[state,accepting]         (D) [below of=B]                       {$s_3$};

\path[->] (A) edge [left]       node [align=center]  {$ c = c + 1 $} (C)
      (A) edge [above]      node [align=center]  {$ c = c + 5 $} (B)
      (A) edge [left]       node [align=center]  {$ c = c - 1 $} (D)
      (B) edge [right]      node [align=center]  {$ c = c - 1 $} (D)
      (C) edge [loop above] node [align=center]  {$ c = c + 1 $} (C)
      (D) edge [loop below] node [align=center]  {$ c = c - 2 $} (D);

\end{tikzpicture}
\caption{An example of SST}
\end{figure}

\end{document}

enter image description here

share|improve this answer
1  
Also, putting option double at those nodes. –  JLDiaz Jul 18 '12 at 9:15
    
Yes, it works too, but I preferred to use accepting since the OP works with the automata library. –  Claudio Fiandrino Jul 18 '12 at 9:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.