LaTeX/TikZ: Finite State Machine / Automata

Finite State Machine Designer
automataLatexGen

Tutorial 17.1a – PGF/Tikz (Modifying coordinates – coordinate calculations)

How to change initial state text in finite state machines with TikZ, automata library?
Controlling edge shape in tikz

Which package can be used to draw automata?
Example: State machine
Drawing Finite State Machines in LATEX using tikz (PDF)
Tikz for state-machines (PDF)
Typesetting figures for computer science (PDF)

Setting bold Greek letters in LaTeX maths

Should \tikzset or \tikzstyle be used to define TikZ styles?
Kann man `every node/.style` spezifizieren außer für nodes auf edges?
tikz state initial with vertical orientation?
Node below and left of another node in TikZ
Changing line thickness of arrow
Wie kann ich die Biegung von TikZ-Pfeilen einstellen?
How do you get two lines between nodes that have paths to each other instead of a double ended line? [duplicate]

How does one pick control points to control Bézier curves in TikZ?
TikZ in/out angle vs. Bezier controls
TikZ: Node at same x-coordinate as another node, but specified y-coordinate?
Wie werden nodes positioniert?

LaTeX Graphics using TikZ: A Tutorial for Beginners (Part 1)—Basic Drawing
LaTeX Graphics using TikZ: A Tutorial for Beginners (Part 2)—Generating TikZ Code from GeoGebra
LaTeX Graphics using TikZ: A Tutorial for Beginners (Part 3)—Creating Flowcharts
LaTeX Graphics using TikZ: A Tutorial for Beginners (Part 4)—Circuit Diagrams Using Circuitikz
LaTeX Graphics using TikZ: A Tutorial for Beginners (Part 5)—Creating Mind Maps

LaTeX/PGF/TikZ

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

\tikzset{
    ->, % makes the edges directed
    >=stealth, % makes the arrow heads bold
    node distance=2cm, % specifies the minimum distance between two nodes. Change if necessary.
    every state/.style={thick, fill=gray!10}, % sets the properties for each ’state’ node
    every edge/.append style={line width=0.25mm}, % sets the properties for each ’state’ node
    initial text=$ $, % sets the text that appears on the start arrow
}

\begin{document}
    \begin{tikzpicture}
        \node[state, initial] (q1) {$q_1$};
        \node[state, accepting, right of=q1] (q2) {$q_2$};
        \node[state, right of=q2] (q3) {$q_3$};
        \draw	(q1) edge[loop above] node{0} (q1)
                (q1) edge[above] node{1} (q2)
                (q2) edge[loop above] node{1} (q2)
                (q2) edge[bend left, above] node{0} (q3)
                (q3) edge[bend left, below] node{0, 1} (q2);
    \end{tikzpicture}
    
    \begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
        \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        {0} (q_1)
                  edge              node [swap] {1} (q_2)
            (q_1) edge              node        {1} (q_3)
                  edge [loop above] node        {0} ()
            (q_2) edge              node [swap] {0} (q_3) 
                  edge [loop below] node        {1} ();
    \end{tikzpicture}
\end{document}

Leave a Reply

Your email address will not be published. Required fields are marked *