[Tex/LaTex] Tikz Paths in Automata

automatatikz-pgf

I'm trying to draw an automata in LaTeX with TikZ, but I don't know how to make a long transition between two states. I need a sized label to be placed on it.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 

   \node[state,initial] (s_0)   {Start 1}; 
   \node[state] (s_1) [right=of s_0] {Start 2}; 
   \node[state] (s_2) [right=of s_1] {Start 3};



    \path[->] 
    (s_0) edge [bend left] node {Path not long enough for text} (s_1);

\end{tikzpicture}
\end{document}

Gives this result:

enter image description here

Anyone here who could help me?

Best Answer

Choose your option.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
  \node[state,initial] (s_0)   {Start 1}; 
  \node[state] (s_1) [right=of s_0] {Start 2}; 
  \node[state] (s_2) [right=of s_1] {Start 3};

  \path[->] (s_0) edge [bend left] node[text width=1.5cm,
                                        align=center
                                       ] {Path not long enough for text} (s_1);
\end{tikzpicture}

\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
  \node[state,initial] (s_0)   {Start 1}; 
  \node[state] (s_1) [right=4cm of s_0] {Start 2};% or [node distance=4cm, right=of s_0]
  \node[state] (s_2) [right=of s_1] {Start 3};

  \path[->] (s_0) edge [bend left] node {Path not long enough for text} (s_1);
\end{tikzpicture}
\end{document}

Output

enter image description here

enter image description here