# Change bend angle and swap node position on arrow

I'm trying to draw an automata as follows:

\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.8cm]
\node[initial,state] (q1)      {$1$};
\node[state]         (q2) [right of=q1]  {$2$};
\node[state] (q4) [below right of=q2] {$4$};
\node[state, accepting]         (q3) [above right of=q4] {$3$};

\path[->]          (q1)  edge                 node {a} (q2);
\path[->]          (q2)  edge   [bend left]   node {b} (q3);
\path[->]          (q3)  edge   [bend left]   node {a} (q2);
\path[->]          (q2)  edge                 node {b} (q4);
\path[->]          (q4)  edge                 node {a} (q3);
\end{tikzpicture}


However, the bending seems to be "too much", and it interferes with the two arrows to/from q4. In addition, I'd like the labels on those two arrows to be on the other side of the arrow. Sadly I couldn't find how to do it online so I turned to this page.

-
– Peter Grill May 30 '12 at 21:39

You can influence the degree of bending using the optional parameter of bend left and bend right. The default is bend left=30, which means that the connecting line leaves and enters the nodes at an angle of 30 degrees to the direct connecting line. bend left=20 would be a more gentle curve. If you want all your curves to curve by the same amount without explicitly specifying it each time, you can add bend angle=20 to your tikzpicture options.

To swap the nodes on the lines to the other side, simply add the key [swap] to the node options.

\documentclass{article}

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

\begin{document}

\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=2.8cm]
\node[initial,state] (q1)      {$1$};
\node[state]         (q2) [right of=q1]  {$2$};
\node[state] (q4) [below right of=q2] {$4$};
\node[state, accepting]         (q3) [above right of=q4] {$3$};

\path[->]          (q1)  edge                 node {a} (q2);
\path[->]          (q2)  edge   [bend left=20]   node {b} (q3);
\path[->]          (q3)  edge   [bend left=20]   node {a} (q2);
\path[->]          (q2)  edge                 node [swap] {b} (q4);
\path[->]          (q4)  edge                 node [swap] {a} (q3);
\end{tikzpicture}

\end{document}

-
Thanks. adding [below] after the node seems to do the trick as well. Is it possible to delete the word "start" (keeping the arrow to q1)? – Bob May 30 '12 at 20:18
@Bob: [below] doesn't quite do the same thing, though. You might notice that the nodes aren't properly centered if you use below, because they are now placed directly below the middle of the line, while using swap takes the angle of the line into account. You can remove the word start by setting initial text={}. – Jake May 30 '12 at 20:20
Thank you very much! :-) – Bob May 30 '12 at 20:26