7

Using Tikzpicture, I have the following automata:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{positioning,arrows,automata}
\begin{center}
\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,initial/.style={}]
\node[state,initial]  (a0)                   {};
\node[state]          (a1)  [right =of a0]   {};
\node[state]          (a2)  [right =of a1]   {};
\node[state]          (a3)  [above =of a2]   {};
\node[state]          (a4)  [below =of a0]   {};
\node[state]          (a6)  [right =of a4]   {};
\node[state]          (a7)  [right =of a2]   {};   
\node[state]          (a8)  [right =of a7]   {};
\node[state]          (a9)  [right =of a8]   {}; 
\node[state]          (a5)  [above =of a9]   {};
\node[state]          (b0)  [right =of a6]   {}; 
\node[state]          (b1)  [right =of b0]   {};
\node[state]          (b2)  [right =of b1]   {}; 
\node[state]          (b3)  [right =of b2]   {};
\node[state]          (b4)  [right =of a9]   {};                                
\tikzset{every node/.style={fill=white}}
\tikzset{mystyle/.style={->,double=red}}  
\path (a4)     edge [mystyle]       node   {$0$} (a6)
      (a2)     edge [mystyle]       node   {$0$} (a7)
      (b0)     edge [mystyle]       node   {$0$} (b1);
\tikzset{mystyle/.style={->,double=blue}}  
\path (a3)     edge [mystyle]       node   {$1$} (a5)
      (a8)     edge [mystyle]       node   {$1$} (a9)
      (b2)     edge [mystyle]       node   {$1$} (b3);              
\tikzset{mystyle/.style={->,double=yellow}}  
\path (a0)     edge [mystyle]       node   {$\varepsilon$} (a1)
      (a1)     edge [mystyle]       node   {$\varepsilon$} (a2)
      (a1)     edge [mystyle]       node   {$\varepsilon$} (a3)
      (a1)     edge [mystyle]       node   {$\varepsilon$} (a4)
      (a6)     edge [mystyle]       node   {$\varepsilon$} (b0)
      (a7)     edge [mystyle]       node   {$\varepsilon$} (a8)
      (b1)     edge [mystyle]       node   {$\varepsilon$} (b2)
      (a9)     edge [mystyle]       node   {$\varepsilon$} (b4)
      (a5)     edge [mystyle]       node   {$\varepsilon$} (b4)
      (b3)     edge [mystyle]       node   {$\varepsilon$} (b4);
\end{tikzpicture}
\end{center}
\end{document}

Result

Now, I want to add a yellow epsilon arrow from the node on the far left (a0) to the node on the far right (b4). However, I have absolutely no idea how to do this without the arrow cutting through the rest of the automata. Can I get some help here?

3
  • Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries. Commented Mar 22, 2013 at 5:48
  • @Minhtam: Add \draw [mystyle] (a0) to [bend left=90] (b4); to draw a curved arrow. You can specify the curvature using the parameter to bend left.
    – Jake
    Commented Mar 22, 2013 at 7:16

1 Answer 1

10

You can use [bend left] option as suggested in a comment, and give it an angle, such as [bend left=70], then the curve will leave then start and ending nodes at that angle, and thus the resulting path is symmetric.

(a0)   edge[mystyle, bend left=70] node {$\varepsilon$} (b4);

However, in this particular case, since the figure is assymetric, this way of producing the path looks a bit ugly (imho):

A bit ugly

Through options in and out you can specify different angles for the endings of the path, and thus create an assymetric arc which fits better with the rest of the figure:

 (a0)   edge[mystyle, out=50,in=90] node {$\varepsilon$} (b4);

Better

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .