Example: Automata

Published 2006-11-08 | Author: The TikZ and PGF manual

This example is from the System layer title page of the TikZ and PGF manual.

Author: Till Tantau
Source: The PGF/TikZ manual

Download as: [PDF] [TEX]

Automata

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}

\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[shorten >=1pt,->]
  \tikzstyle{vertex}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]

  \foreach \name/\x in {s/1, 2/2, 3/3, 4/4, 15/11, 
                        16/12, 17/13, 18/14, 19/15, t/16}
    \node[vertex] (G-\name) at (\x,0) {$\name$};

  \foreach \name/\angle/\text in {P-1/234/5, P-2/162/6, 
                                  P-3/90/7, P-4/18/8, P-5/-54/9}
    \node[vertex,xshift=6cm,yshift=.5cm] (\name) at (\angle:1cm) {$\text$};

  \foreach \name/\angle/\text in {Q-1/234/10, Q-2/162/11, 
                                  Q-3/90/12, Q-4/18/13, Q-5/-54/14}
    \node[vertex,xshift=9cm,yshift=.5cm] (\name) at (\angle:1cm) {$\text$};

  \foreach \from/\to in {s/2,2/3,3/4,3/4,15/16,16/17,17/18,18/19,19/t}
    \draw (G-\from) -- (G-\to);

  \foreach \from/\to in {1/2,2/3,3/4,4/5,5/1,1/3,2/4,3/5,4/1,5/2}
    { \draw (P-\from) -- (P-\to); \draw (Q-\from) -- (Q-\to); }

  \draw (G-3) .. controls +(-30:2cm) and +(-150:1cm) .. (Q-1);
  \draw (Q-5) -- (G-15);
\end{tikzpicture}

\end{document}

Comments

  • #1 Matthias Greiner, November 21, 2009 at 12:25 a.m.

    I wonder whether graphs can be drawn using TikZ with automatic placement of the nodes (similar to what Graphviz or Rgraphviz can do. ... and thanks for this nice and inspiring work. Matthias

  • #2 Kjell Magne Fauske, November 21, 2009 at 9:26 a.m.

    You could try dot2tex. Dot2tex can convert graph layouts generated by Graphviz to TikZ code.

Adding comments is currently not enabled.