Automata 1


automata1

พอลองหัดเล่นแล้วต้องแก้รหัสต้นในคู่มือของ PGF/TikZ นิดหน่อยก็เลยเอาเก็บไว้ดูต่างหน้า

% Author: Till Tantau
% Source: The PGF/TikZ manual

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,shadows}
\usepackage[latin1]{inputenc}
\usepackage{verbatim}

\begin{document}

\begin{comment}
:Title: State machine
:Tags: Manual, Automata, Graphs Another examle from the manual.

| Author: Till Tantau
| Source: The PGF/TikZ manual
\end{comment}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,>=stealth’,thick,
      every state/.style={fill,draw=none,orange,circular drop shadow,text=white},
      accepting/.style ={green!50!black,text=white},
      initial/.style ={red,text=white}]

\node[state,initial]                  (q_0)                                        {$q_0$};
\node[state]                            (q_1)   [above right of= q_0]    {$q_1$};
\node[state]                            (q_2)   [below right of= q_0]    {$q_2$};
\node[state,accepting]           (q_3)   [below right of= q_1]    {$q_3$};

\path[->]    (q_0)    edge                                node    [above left]   {0}   (q_1)
                              edge                                node    [below left]   {1}   (q_2)
                  (q_1)    edge                                node    [above right] {1}   (q_3)
                              edge [loop above]           node                          {0}   ( )
                  (q_2)    edge                                node    [below right] {0}   (q_3)
                              edge [loop below]           node                          {1}   ( );
\end{tikzpicture}
\end{document}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s