0

I wanted final states to be the same size as non-final states. The only difference between finals and non-finals should be the existence of the double circle in the final states.

Does anyone know how to do this?

This is the code:

              \documentclass{article}
               \usepackage{geometry}
              \usepackage{tikz}
               \usetikzlibrary{arrows.meta,
chains,
fit,
positioning,
quotes}

                    \begin{document}
                \begin{center}
                   \begin{tikzpicture}[
    node distance = 12mm and 12mm,
    start chain = going right,
    arr/.style = {draw, semithick, rounded corners, -Straight Barb},
    N/.style = {draw, circle, fill=none, minimum size=1pt, outer sep=3pt,
        font=\tiny},
    EN/.style = {circle, draw,double,double distance=1.5pt, inner sep=0pt, outer sep=0.1pt,
        fit={#1}, node contents={}},
    every edge/.style = {draw, arr},
    ]
    % position the nodes a...d
    \coordinate[label=left:I] (a);
    \node (b) [N, right=of a] {$q_1$};
    \node (c) [N, above right=of b] {$q_2$};
    % position the nodes d...i
    \begin{scope}[nodes={on chain}]
    \node (d) [N, below right=of c] {$q_3$};
    \foreach \i in {e, f,...,i}
    \node (\i) [N] {$q_\i$};
    \end{scope}
    \node (ei) [EN=(i)];
    \path   (a) edge                    (b)
    (b) edge["$\varepsilon$"]   (c)
    (c) edge["$\varepsilon$"]   (d)
    (d) edge["0"]               (e)
    (e) edge["$\varepsilon$"]   (f)
    (f) edge["0"]               (g)
    (g) edge["$\varepsilon$"]   (h)
    (h) edge["1"]               (ei)
    ;
    \draw[arr]  (ei) |- ([yshift=45mm] b.north west)
    to ["$\varepsilon$" '] (b.north west);
    %%%%
    \begin{scope}[nodes={on chain}]
    \node (j) [N, above right=of c] {$q_j$};
    \foreach \i in {k, l, m}
    \node (\i) [N] {$q_\i$};
    \end{scope}
    \node (em) [EN=(m)];
    \path   (c) edge["$\varepsilon$"]   (j)
    (j) edge["1"]               (k)
    (k) edge["$\varepsilon$"]   (l)
    (l) edge["0"]               (em);
    \draw[arr]  (em) |- ([yshift=42mm] b.north)
    to ["$\varepsilon$"] (b);
    %%%%
    \begin{scope}[nodes={on chain}]
    \node (n) [N, below right=of b] {$q$};
    \foreach \i in {o, p,...,s}
    \node (\i) [N] {$q_\i$};
    \end{scope}
    \node (es) [EN=(s)];
    \path   (b) edge["$\varepsilon$"]   (n)
    (n) edge["0"]               (o)
    (o) edge["$\varepsilon$"]   (p)
    (p) edge["1"]               (q)
    (q) edge["$\varepsilon$"]   (r)
    (r) edge["0"]               (es);
    \draw[arr]  (es) |- ([yshift=-22mm] b.south)
    to ["$\varepsilon$"] (b);
    \end{tikzpicture}
\end{center}
         \end{document}

This is the output I got (with triple circle at final states):

enter image description here

2
  • 1
    Please check your MWE. Currently, it contains two documents.
    – user187803
    Apr 26 at 5:23
  • As I see, you use my answer, but why than you not accept it? It is not entirely clear, what is your problem. If you like to change size of last node, please correct style of EN accordingly
    – Zarko
    Apr 26 at 22:02

1 Answer 1

0

I guess that you may liked (or you after) the following solution

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                fit,
                positioning,
                quotes}

\begin{document}
\begin{center}
    \begin{tikzpicture}[
node distance = 12mm and 12mm,
  start chain = going right,
   arr/.style = {draw, semithick, rounded corners, -Straight Barb},
     N/.style = {circle, draw, fill=none, minimum size=1em, 
                 outer sep=3pt, font=\tiny},
    EN/.style = {N, double, double distance=1.5pt},
every edge/.style = {draw, arr},
                    ]
% position the nodes a...d
\coordinate[label=left:I] (a);
\node (b) [N, right=of a] {$q_1$};
\node (c) [N, above right=of b] {$q_2$};
% position the nodes d...i
    \begin{scope}[nodes={on chain}]
\node (d) [N, below right=of c] {$q_3$};
\foreach \i in {e, f,...,h}
\node (\i) [N] {$q_\i$};
    \end{scope}
\node (ei) [EN, right=of h] {$q_i$};
\path   (a) edge                    (b)
(b) edge["$\varepsilon$"]   (c)
(c) edge["$\varepsilon$"]   (d)
(d) edge["0"]               (e)
(e) edge["$\varepsilon$"]   (f)
(f) edge["0"]               (g)
(g) edge["$\varepsilon$"]   (h)
(h) edge["1"]               (ei)
;
\draw[arr]  (ei) |- ([yshift=45mm] b.north west)
to ["$\varepsilon$" '] (b.north west);
%%%%
\node (j) [N, above right=of c] {$q_j$};
\node (k) [N, right=of j] {$q_k$};
\node (l) [N, right=of k] {$q_l$};
\node (m) [N, right=of l] {$q_m$};
\node (em) [EN, right=of l] {$q_m$};
\path   (c) edge["$\varepsilon$"]   (j)
        (j) edge["1"]               (k)
        (k) edge["$\varepsilon$"]   (l)
        (l) edge["0"]               (em);
\draw[arr]  (em) |- ([yshift=42mm] b.north)
                 to ["$\varepsilon$"] (b);
%%%%
    \begin{scope}[nodes={on chain}]
\node (n) [N, below right=of b] {$q$};
\foreach \i in {o, p,...,r}
\node (\i) [N] {$q_\i$};
    \end{scope}
\node (es) [EN, right=of r] {$q_s$};
\path   (b) edge["$\varepsilon$"]   (n)
        (n) edge["0"]               (o)
        (o) edge["$\varepsilon$"]   (p)
        (p) edge["1"]               (q)
        (q) edge["$\varepsilon$"]   (r)
        (r) edge["0"]               (es);
\draw[arr]  (es) |- ([yshift=-22mm] b.south)
                 to ["$\varepsilon$"] (b);
    \end{tikzpicture}
\end{center}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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