# Trying to draw a picture of an automata in TexMaker using Tikz

I'm looking for some help drawing automata in TexMaker. My problem is that the lines of the automata cross and it makes the whole thing a bit unreadable.

MWE:

\documentclass[a4paper,twoside,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=2.5cm,on grid,auto]
\node[state,initial] (0) {$q_0$};
\node[state] (1) [right=of 0] {$q_1$};
\node[state, accepting] (2) [right=of 1] {$q_2$};
\node[state, accepting] (3) [right=of 2] {$q_3$};
\node[state] (4) [right=of 3] {$q_4$};
\path[->]
(0) edge [bend left]    node {$a$} (2)
(0) edge [loop below]   node {$b$} (0)
(0) edge                node {$c$} (1)
(1) edge                node {$a$} (2)
(1) edge [bend left]    node {$b$} (4)
(1) edge [loop below]   node {$c$} (1)
(2) edge [bend right]   node {$a$} (0)
(2) edge [loop below]   node {$b$} (2)
(2) edge                node {$c$} (3)
(3) edge [bend right]   node {$a$} (0)
(3) edge                node {$b$} (4)
(3) edge [loop below]   node {$c$} (3)
(4) edge [loop below]   node {$a$, $b$, $c$} (4);
\end{tikzpicture}

\end{document}

• Please copy the code into the question, don't use an external hosting cite. – Stefan Kottwitz Nov 20 '15 at 16:41
• The bend options can take a value that controls how bent they are. This way you can manually avoid overlapping – Bordaigorl Nov 20 '15 at 16:43

The bend options can take a value that controls how bent they are. This way you can manually avoid overlapping. In this case you can make the edges pointing to (0) go below the states and to avoid clash with the loops they can be bent at a 60 degrees angle with bend left=60.

\documentclass[a4paper,twoside,11pt]{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}

\begin{document}

\begin{tikzpicture}[shorten >=1pt,node distance=2.5cm,on grid,auto]
\node[state,initial] (0) {$q_0$};
\node[state] (1) [right=of 0] {$q_1$};
\node[state, accepting] (2) [right=of 1] {$q_2$};
\node[state, accepting] (3) [right=of 2] {$q_3$};
\node[state] (4) [right=of 3] {$q_4$};
\path[->]
(0) edge [bend left]    node {$a$} (2)
(0) edge [loop below]   node {$b$} (0)
(0) edge                node {$c$} (1)
(1) edge                node {$a$} (2)
(1) edge [bend left]    node {$b$} (4)
(1) edge [loop below]   node {$c$} (1)
(2) edge [bend left=60]   node {$a$} (0)
(2) edge [loop below]   node {$b$} (2)
(2) edge                node {$c$} (3)
(3) edge [bend left=60]   node {$a$} (0)
(3) edge                node {$b$} (4)
(3) edge [loop below]   node {$c$} (3)
(4) edge [loop below]   node {$a$, $b$, $c$} (4);
\end{tikzpicture}

\end{document}


• Thank you for your speedy answer. I'll experiment a bit with the angling of the bend left/right command. – Carst Nov 20 '15 at 17:03
• @Carst if you want to know more about the bend param, here I explain how the parameters work and how to visualise them in the picture tex.stackexchange.com/a/223095/36686 – Bordaigorl Nov 20 '15 at 22:02