summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex')
-rw-r--r--Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex222
1 files changed, 124 insertions, 98 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex
index 4f587a8bbab..2cc4021316e 100644
--- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex
+++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-library-automata.tex
@@ -29,7 +29,7 @@ To draw an automaton, proceed as follows:
\item For each state of the automaton, there should be one node with
the option |state|.
\item To place the states, you can either use absolute positions or
- relative positions, using options like |above of| or |right of|.
+ relative positions, using options like |above| or |right|.
\item Give a unique name to each state node.
\item Accepting and initial states are indicated by adding the
options |accepting| and |initial|, respectively, to the state
@@ -44,13 +44,13 @@ Let us now see how this works for a real example. Let us consider a
nondeterminsitic four state automaton that checks whether an contains
the sequence $0^*1$ or the sequence $1^*0$.
\begin{codeexample}[]
-\begin{tikzpicture}[shorten >=1pt,node distance=2cm,auto]
+\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\draw[help lines] (0,0) grid (3,2);
\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$};
+ \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 {0} (q_1)
edge node [swap] {1} (q_2)
@@ -70,11 +70,12 @@ then simply set the |state| style to your given style to get the
desired kind of styles.
By default, the following state styles are defined:
-\begin{itemize}
- \itemstyle{state without output}
+\begin{stylekey}{/tikz/state without output}
This node style causes nodes to be drawn circles. Also, this style
calls |every state|.
- \itemstyle{state with output}
+\end{stylekey}
+
+\begin{stylekey}{/tikz/state with output}
This node style causes nodes to be drawn as split circles, that is,
using the |circle split| shape. In the upper part of the shape you
have the name of the style, in the lower part the output is
@@ -89,30 +90,30 @@ By default, the following state styles are defined:
\node[state with output] at (2,0) {$q_1$ \nodepart{lower} $00$};
\end{tikzpicture}
\end{codeexample}
+\end{stylekey}
- \itemstyle{state}
- This style is set to |state without output| by default. You should
- redefine it to something else, if you wish to use states of a
- different nature.
+\begin{stylekey}{/tikz/state (initially state without output)}
+ You should redefine it to something else, if you wish to use states
+ of a different nature.
\begin{codeexample}[]
-\begin{tikzpicture}
- \tikzstyle{state}=[state with output]
+\begin{tikzpicture}[state/.style=state with output]
\node[state] {$q_0$ \nodepart{lower} $11$};
\node[state] at (2,0) {$q_1$ \nodepart{lower} $00$};
\end{tikzpicture}
\end{codeexample}
+\end{stylekey}
- \itemstyle{every state}
+\begin{stylekey}{/tikz/every state (initially \normalfont empyt)}
This style is used by |state with output| and also by
|state without output|. By default, it does nothing, but you can use
it to make your state look more fancy:
\begin{codeexample}[]
-\begin{tikzpicture}[shorten >=1pt,node distance=2cm,>=stealth']
- \tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
+\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth',
+ every state/.style={draw=blue!50,very thick,fill=blue!20}]
\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] (q_1) [above right=of q_0] {$q_1$};
+ \node[state] (q_2) [below right=of q_0] {$q_2$};
\path[->] (q_0) edge node [above left] {0} (q_1)
edge node [below left] {1} (q_2)
@@ -120,7 +121,7 @@ By default, the following state styles are defined:
(q_2) edge [loop below] node {1} ();
\end{tikzpicture}
\end{codeexample}
-\end{itemize}
+\end{stylekey}
\subsection{Initial and Accepting States}
@@ -129,83 +130,104 @@ The styles |initial| and |accepting| are similar to the |state| style
as they also just select an ``underlying'' style, which installs the
actual settings for initial and accepting states.
-For initial states, there is only one predefined way of drawing them,
-so the two-stage mechanism is not really necessary, but, perhaps,
-I will find another way of drawing them in the literature some time.
-
Let us start with the initial states.
-\begin{itemize}
- \itemstyle{initial}
- This style simply selects |initial by arrow|.
- \itemstyle{initial by arrow}
+\begin{stylekey}{/tikz/initial (initially initial by arrow)}
+ This style is used to draw initial states.
+\end{stylekey}
+\begin{stylekey}{/tikz/initial by arrow}
This style causes an arrow and, possibly, some text to be added to
the node. The arrow points from the text to the node. The node text
and the direction and the distance can be set using the following
- options:
- \begin{itemize}
- \itemoption{initial text}|=|\meta{text} sets the text to be
- used. Use an empty text to suppress all text. The default is
- |start|.
- \itemoption{initial where}|=|\meta{direction} set the place where
- the text should be shown. Allowed values are |above|, |below|,
- |left|, and |right|.
- \itemoption{intial distance}|=|\meta{distance} is the length of the
- arrow leading from the text to the state node.
- \end{itemize}
- \itemstyle{every initial by arrow}
- This style is executed at the beginning of every path that contains
- the arrow and the text. You can use it to, say, make the text red or
- whatever.
+ key:
+ \begin{key}{/tikz/initial text=\meta{text} (initially start)}
+ This key sets the text to be used. Use an empty text to suppress
+ all text.
+ \end{key}
+ \begin{key}{/tikz/initial where=\meta{direction} (initially left)}
+ Set the place where the text should be shown. Allowed values are
+ |above|, |below|, |left|, and |right|.
+ \end{key}
+ \begin{key}{/tikz/intial distance=\meta{distance} (initially 3ex)}
+ Sets the length of the arrow leading from the text to the state
+ node.
+ \end{key}
+ \begin{stylekey}{/tikz/every initial by arrow (initially \normalfont empty)}
+ This style is executed at the beginning of every path that contains
+ the arrow and the text. You can use it to, say, make the text red or
+ whatever.
+ \end{stylekey}
\begin{codeexample}[]
-\begin{tikzpicture}
- \tikzstyle{every initial by arrow}=[text=red,->>]
+\begin{tikzpicture}[every initial by arrow/.style={text=red,->>}]
\node[state,initial,initial distance=2cm] {$q_0$};
\end{tikzpicture}
\end{codeexample}
- \itemstyle{initial above} is a shorthand for
- |initial by arrow,initial where=above|
- \itemstyle{initial below} works similarly to the previous option.
- \itemstyle{initial left} works similarly to the previous option.
- \itemstyle{initial right} works similarly to the previous option.
-\end{itemize}
+ %<<
+\end{stylekey}
+\begin{stylekey}{/tikz/initial above}
+ This is a shorthand for |initial by arrow,initial where=above|.
+\end{stylekey}
+\begin{stylekey}{/tikz/initial below}
+ Works similarly to the previous option.
+\end{stylekey}
+\begin{stylekey}{/tikz/initial left}
+ Works similarly to the previous option.
+\end{stylekey}
+\begin{stylekey}{/tikz/initial right}
+ Works similarly to the previous option.
+\end{stylekey}
+
+\begin{stylekey}{/tikz/initial by diamond}
+ This style uses a diamond to indicate an initial node.
+\end{stylekey}
For the accepting states, the sitation is similar: There is also an
|accepting| style that selects the way accepting states are
-rendered. However, there are now two options: First,
+rendered. There are now two options: First,
|accepting by arrow|, which works the same way as |initial by arrow|,
only with the direction of arrow reversed, and |accepting by double|,
where accepting states get a double line around them.
-\begin{itemize}
- \itemstyle{accepting}
- This style selects |accepting by double| by default. You can replace
+\begin{stylekey}{/tikz/accepting (initially accepting by double)}
+ This style is used to draw accepting states. You can replace
this by the style |accepting by arrow| to get accepting states with
an arrow leaving them.
- \itemstyle{accepting by double}
- Specifies that the node should get a double line around it.
- \itemstyle{accepting by arrow}
+\end{stylekey}
+
+\begin{stylekey}{/tikz/accepting by double}
+ This style causes a double line to be drawn arond a state.
+\end{stylekey}
+
+\begin{stylekey}{/tikz/accepting by arrow}
This style causes an arrow and, possibly, some text to be added to
the node. The arrow points to the text from the node.
- \begin{itemize}
- \itemoption{accepting text}|=|\meta{text} sets the text to be
- used. Use an empty text to suppress all text. This is the default.
- \itemoption{accepting where}|=|\meta{direction} set the place where
- the text should be shown. Allowed values are |above|, |below|,
- |left|, and |right|.
- \itemoption{intial distance}|=|\meta{distance} is the length of the
- arrow.
- \end{itemize}
+
+ The same options as for initial states can be used, only with
+ |initial| replaced by |accepting|:
+ \begin{key}{/tikz/accepting text=\meta{text} (initially \normalfont empty)}
+ This key sets the text to be used.
+ \end{key}
+ \begin{key}{/tikz/accepting where=\meta{direction} (initially right)}
+ Set the place where the text should be shown. Allowed values are
+ |above|, |below|, |left|, and |right|.
+ \end{key}
+ \begin{key}{/tikz/intial distance=\meta{distance} (initially 3ex)}
+ Sets the length of the arrow leading from the text to the state
+ node.
+ \end{key}
+ \begin{stylekey}{/tikz/every accepting by arrow (initially \normalfont empty)}
+ Executed at the beginning of every path that contains
+ the arrow and the text.
+ \end{stylekey}
\begin{codeexample}[]
\begin{tikzpicture}
- [shorten >=1pt,node distance=2cm,>=stealth',initial text=]
-
- \tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
- \tikzstyle{accepting}=[accepting by arrow]
+ [shorten >=1pt,node distance=2cm,on grid,>=stealth',initial text=,
+ every state/.style={draw=blue!50,very thick,fill=blue!20},
+ accepting/.style=accepting by arrow]
\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$};
+ \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)
@@ -215,15 +237,20 @@ where accepting states get a double line around them.
edge [loop below] node {1} ();
\end{tikzpicture}
\end{codeexample}
- \itemstyle{every accepting by arrow}
- This style is executed at the beginning of every path that contains
- the arrow and the text.
- \itemstyle{accepting above} is a shorthand for
- |accepting by arrow,accepting where=above|
- \itemstyle{accepting below} works similarly to the previous option.
- \itemstyle{accepting left} works similarly to the previous option.
- \itemstyle{accepting right} works similarly to the previous option.
-\end{itemize}
+\end{stylekey}
+
+\begin{stylekey}{/tikz/accepting above}
+ This is a shorthand for |accepting by arrow,accepting where=above|.
+\end{stylekey}
+\begin{stylekey}{/tikz/accepting below}
+ Works similarly to the previous option.
+\end{stylekey}
+\begin{stylekey}{/tikz/accepting left}
+ Works similarly to the previous option.
+\end{stylekey}
+\begin{stylekey}{/tikz/accepting right}
+ Works similarly to the previous option.
+\end{stylekey}
@@ -236,15 +263,15 @@ green, and normal states are orange. Then, we must find a path from a
red state to a green state.
\begin{codeexample}[]
-\begin{tikzpicture}[shorten >=1pt,node distance=2cm,>=stealth',thick]
- \tikzstyle{every state}=[fill,draw=none,orange,text=white]
- \tikzstyle{accepting}=[green!50!black,text=white]
- \tikzstyle{initial}= [red,text=white]
+\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,>=stealth',thick,
+ every state/.style={fill,draw=none,orange,text=white,circular drop shadow},
+ 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$};
+ \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)
@@ -260,17 +287,16 @@ beaver:
\begin{codeexample}[]
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,%
- auto,node distance=2cm,semithick,
+ auto,node distance=2cm,on grid,semithick,
inner sep=2pt,bend angle=45]
\node[initial,state] (A) {$q_a$};
- \node[state] (B) [above right of=A] {$q_b$};
- \node[state] (D) [below right of=A] {$q_d$};
- \node[state] (C) [below right of=B] {$q_c$};
- \node[state] (E) [below of=D] {$q_e$};
+ \node[state] (B) [above right=of A] {$q_b$};
+ \node[state] (D) [below right=of A] {$q_d$};
+ \node[state] (C) [below right=of B] {$q_c$};
+ \node[state] (E) [below=of D] {$q_e$};
- \tikzstyle{every node}=[font=\footnotesize]
-
- \path (A) edge node {0,1,L} (B)
+ \path [every node/.style={font=\footnotesize}]
+ (A) edge node {0,1,L} (B)
edge node {1,1,R} (C)
(B) edge [loop above] node {1,1,L} (B)
edge node {0,1,L} (C)