[Tex/LaTex] Separating edges starting from same node

tikz-pgf

I have following code –

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,calc,shapes, positioning}

\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,node distance=3.0cm,thick]
  \tikzstyle{every state}=[fill=white,draw=black,text=black,minimum size=45pt]

  \node[state]         (A) {$A$};
  \node[state]         (B) [right of=A] {$B$};
  \node[state]         (C) [right of=B] {$C$};


  \path (A) [loop above] edge (A);
  \path (A) edge (B) 
        (B)  edge  (C) 
        (A) edge [bend left=45] node [above, xshift=-2mm,yshift=-3.5mm,very near start] {$1$} (B)  
        (A) edge [bend left=45] (C);

 % Hard-coded the token location since i don't know about it.
 \fill[black] (0.00,1.75) circle  (2pt);
\end{tikzpicture}

\end{document}

This generates an image like this –

enter image description here

However, I would like to add some text to the edges. Thus I want to have my output something like this –
enter image description here

How can I achieve this in the Tikz?

Thanks !
Raj

Best Answer

Every tikz node has 360 anchor points using the notation nodename.angle, being angle an integer between 0 and 360. Those anchors are placed at the intersection between the node shape and a radius with the given angle. You can use those anchors to set the starting point of the arcs, and also for the labels with $1$.

UPDATE: Also, a small improvement about the dot you place "manually". It is more convenient giving the coordinates of that point in polar coordinates with respect node A. The point is located at 9mm at north of A.north, so you can specify its coordinates as (A.north) +(90:9.1mm). The 9.1mm part is still manually estimated, but making the coordinates relative saves you from recalculate them if you move the A node.

Quoting only the relevant part:

  \path (A) [loop above] edge (A);
  \path (A) edge (B) 
        (B) edge  (C) 
        (A.20) edge [bend left=30]  (B)  
        (A.22) node[above] {$1$}
        (A.50) edge [bend left=45] (C)
        (A.52) node[above] {$1$};

  \fill[black] (A.north) +(90:9.1mm) circle  (2pt);

Produces:

Result

Second update

The proper way of adding the token in the edge is to use a markings decoration. The syntax is a bit utgly because the decoration has to be added in a postaction, but using the example provided below you can easily add tokens to any edge in your graph.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{arrows,automata,decorations.markings}
\tikzset{ % Use this style and postaction={decorate} to put a token in an edge
  put token/.style={
     decoration={markings, mark=at position 0.5 with {\fill[red] circle(2pt); }},
  },
}

\begin{tikzpicture}[node distance=3.0cm,thick]
  \tikzset{
    every state/.append style={fill=white,draw=black,text=black,minimum size=45pt},
    every edge/.append style={->,>=stealth',shorten >=1pt}
  }

  \node[state]   (A) {$A$};
  \node[state]   (B) [right of=A] {$B$};
  \node[state]   (C) [right of=B] {$C$};

  \path (A) edge[loop above, put token, postaction={decorate}] (A);
  \path (A) edge (B) 
        (B) edge  (C) 
        (A.20) edge [bend left=30]  (B)  
        (A.22) node[above] {$1$}
        (A.50) edge [bend left=45] (C)
        (A.52) node[above] {$1$};
\end{tikzpicture}
\end{document}

Result