2

I tried to draw the following FSA to the best of my abilities, but still certain edges are not showing well (because they are not curvy) and state 1 is not aligned with the rest.

Is it possible to:

  1. perhaps make the states slightly smaller

  2. align 1 with 2 (so it is right above)

  3. make the edges go properly for q1 -> q6, etc. instead of going over state 3 it should be curvy, for example.

  4. give some space for edge 1->4 and 2->3 so I can have words for both of them.

MWE:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.text,topaths,arrows.meta,decorations.pathmorphing,quotes}


\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
   \node[state] (q_0)   {$0$}; 
   \node[state] (q_1) [above right=of q_0]  {$1$}; 
   \node[state] (q_2) [right=of q_0]  {$2$}; 
   \node[state] (q_11) [below=of q_2]  {$11$}; 
   \node[state] (q_3) [above right=of q_2]  {$3$}; 
   \node[state] (q_4) [below right=of q_3]  {$4$}; 
   \node[state] (q_5) [right=of q_3]  {$5$}; 
   \node[state] (q_6) [right=of q_5]  {$6$}; 
   \node[state] (q_7) [below right=of q_5] {$7$}; 
   \node[state] (q_8) [right=of q_7]  {$8$}; 
   \node[state] (q_9) [right=of q_8]  {$9$}; 
   \node[state] (q_10) [right=of q_9]  {$10$}; 

    \path[->] 
    (q_0) edge  node [swap] {b} (q_1)
      edge  node [swap] {b} (q_2)
      edge  node [swap] {b} (q_11)
    (q_1) edge  node [swap] {b} (q_4)
      edge  node [swap] {b} (q_5)
      edge  node [swap] {b} (q_6)
    (q_2) edge  node [swap] {b} (q_3)
      edge  node [swap] {b} (q_4)
    (q_4) edge  node [swap] {b} (q_7)
    (q_6) edge  node [swap] {b} (q_8)
    (q_7) edge  node [swap] {b} (q_8)
    (q_8) edge  node [swap] {b} (q_9)
    (q_9) edge  node [swap] {b} (q_10)
    (q_11) edge  node [swap] {b} (q_4);
\end{tikzpicture}

\end{document}
  • The code wasn't previewing correctly, because you cannot go straight from an enumeration point (4. in your case) into an MWE. So I just added a blank line, so that MWE: was not part of point 4. – Steven B. Segletes Apr 27 '18 at 14:41
2

You can use the in and out keys to make the edges "curvy".

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.text,topaths,arrows.meta,decorations.pathmorphing,quotes}


\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
   \node[state] (q_0)   {$0$}; 
   \node[state] (q_2) [right=of q_0]  {$2$}; 
   \node[state] (q_1) [above={sqrt(2)*1cm} of q_2]  {$1$}; 
   \node[state] (q_11) [below=of q_2]  {$11$}; 
   \node[state] (q_3) [above right=of q_2]  {$3$}; 
   \node[state] (q_4) [below right=of q_3]  {$4$}; 
   \node[state] (q_5) [right=of q_3]  {$5$}; 
   \node[state] (q_6) [right=of q_5]  {$6$}; 
   \node[state] (q_7) [below right=of q_5] {$7$}; 
   \node[state] (q_8) [right=of q_7]  {$8$}; 
   \node[state] (q_9) [right=of q_8]  {$9$}; 
   \node[state] (q_10) [right=of q_9]  {$10$}; 

    \path[->] 
    (q_0) edge  node [swap] {b} (q_1)
      edge  node [swap] {b} (q_2)
      edge  node [swap] {b} (q_11)
    (q_1) edge  node [pos=0.8] {b} (q_4)
      edge[in=135,out=45]  node [swap] {b} (q_5)
      edge[in=135,out=90]  node [swap] {b} (q_6)
    (q_2) edge  node [swap] {b} (q_3)
      edge  node [swap] {b} (q_4)
    (q_4) edge  node [swap] {b} (q_7)
    (q_6) edge  node [swap] {b} (q_8)
    (q_7) edge  node [swap] {b} (q_8)
    (q_8) edge  node [swap] {b} (q_9)
    (q_9) edge  node [swap] {b} (q_10)
    (q_11) edge  node [swap] {b} (q_4);
\end{tikzpicture}

\end{document}

enter image description here

Personally I'd move the 3 node a bit to the right.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.text,topaths,arrows.meta,decorations.pathmorphing,quotes}


\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
   \node[state] (q_0)   {$0$}; 
   \node[state] (q_2) [right=of q_0]  {$2$}; 
   \node[state] (q_1) [above={sqrt(2)*1cm} of q_2]  {$1$}; 
   \node[state] (q_11) [below=of q_2]  {$11$}; 
   \node[state] (q_3) [right=of q_1]  {$3$}; 
   \node[state] (q_4) [below right=of q_3]  {$4$}; 
   \node[state] (q_5) [right=of q_3]  {$5$}; 
   \node[state] (q_6) [right=of q_5]  {$6$}; 
   \node[state] (q_7) [below right=of q_5] {$7$}; 
   \node[state] (q_8) [right=of q_7]  {$8$}; 
   \node[state] (q_9) [right=of q_8]  {$9$}; 
   \node[state] (q_10) [right=of q_9]  {$10$}; 

    \path[->] 
    (q_0) edge  node [swap] {b} (q_1)
      edge  node [swap] {b} (q_2)
      edge  node [swap] {b} (q_11)
    (q_1) edge  node [pos=0.8] {b} (q_4)
      edge[in=135,out=45]  node [swap] {b} (q_5)
      edge[in=135,out=90]  node [swap] {b} (q_6)
    (q_2) edge  node [swap] {b} (q_3)
      edge  node [swap] {b} (q_4)
    (q_4) edge  node [swap] {b} (q_7)
    (q_6) edge  node [swap] {b} (q_8)
    (q_7) edge  node [swap] {b} (q_8)
    (q_8) edge  node [swap] {b} (q_9)
    (q_9) edge  node [swap] {b} (q_10)
    (q_11) edge  node [swap] {b} (q_4);
\end{tikzpicture}

\end{document}

enter image description here

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.