# Arc between arrows in TikZ (automata library)

Here's what I have for now:

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3.5cm,
semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]

\node[state]               (s0) {$s_0$};
\node[state]               (s1) [above left of =s0]   {$s_1$};
\node[state]               (s2) [below left of =s0]   {$s_2$};

\path (s0)  edge [bend left] node {$a$} (s1)
(s0)  edge [bend right] node {$b$} (s2);

\end{tikzpicture}


I would like to know if it is possible to add an arc between two arrows:

Any help will be appreciated, thanks!

-

One solution is to use intersections library:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\usetikzlibrary{arrows}
\usetikzlibrary{intersections}
\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,
node distance=3.5cm,semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]

\node[state] (s0) {$s_0$};
\node[state] (s1) [above left of =s0] {$s_1$};
\node[state] (s2) [below left of =s0] {$s_2$};

\draw[name path=e1] (s0) to [bend left] node {$a$} (s1);
\draw[name path=e2] (s0) to [bend right] node {$b$} (s2);

\path[name path=c] (s0) circle (1);
\draw[name intersections={of=e1 and c, by=i1},
name intersections={of=e2 and c, by=i2},
-,shorten >=0pt]
(i1) to[bend right] (i2); % well, it isn't an arc
\end{tikzpicture}

\end{document}


-
Wow thanks! This works indeed! – pp35377 Aug 10 '11 at 16:05

You can also create nodes along the bend edges by using the pos option. So modifying the code

\begin{tikzpicture}[->,>=stealth,shorten >=1pt,auto,node distance=3.5cm,semithick, bend angle=35]
\tikzstyle{every state}=[fill=none,draw=black,text=black,shape=circle]

\node[state]               (s0) {$s_0$};
\node[state]               (s1) [above left of =s0]   {$s_1$};
\node[state]               (s2) [below left of =s0]   {$s_2$};

\path (s0)  edge [bend left]   node[inner sep=0mm,pos=0.2] (a1) {} node {$a$} (s1);
\path (s0)  edge [bend right]  node[inner sep=0mm,pos=0.2] (b1) {} node {$b$} (s2);
\path[-,shorten <=-1.5pt,shorten >=0mm] (a1) edge [bend right]  (b1) ;
\end{tikzpicture}


leads to a similar result by connecting the additional a1 and b1 nodes.

shorten bits are added not to alter your general style settings.

-
Instead of pos=.2 you can also use near start (=pos=.25). This puts the arc a little further along the path but might be easier to remember. – Alan Munn Aug 10 '11 at 16:48
That's correct but this gives a little more freedom and avoids trying to remember something like -"What was it between near start and midway?" as I frequently do. – percusse Aug 10 '11 at 16:52
Yes this is also nice, thanks percusse and Alan ;) – pp35377 Aug 10 '11 at 17:14
@percusse: This method seems better, if the edges have the same lengths. BTW, instead of ugly shorten <=-1.5pt, you should use auto=false to define (a1) and (b1). – Leo Liu Aug 11 '11 at 4:25
@Leo: Thanks, I did not know that. Should come in handy later. :) – percusse Aug 11 '11 at 9:08