39
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm,
                thick,main node/.style={circle,draw,font=\Large\bfseries}]

  \node[main node] (1) {1};
  \node[main node] (2) [below left of=1] {2};
  \node[main node] (3) [below right of=1] {3};

  \path
    (1) edge [loop above] node {0.6} (1)
        edge [bend right] node {0.4} (2)
    (2) edge node [below]{1.0} (1)
    (3) edge [loop below] node {0.8} (3)
        edge node[right] {0.1} (1)
        edge node[below] {0.1} (2);      
\end{tikzpicture}

Output:

What I want is loop with 0.8 to be placed as I drawn in red (something between right and below option).
How can I do that?
I tried (3) edge [loop below right] node {0.8} (3) and it didn't work.

1

3 Answers 3

49

For example, specifying angles for in and out:

\draw (3) to [out=330,in=300,looseness=8] (3);

loop

10

In tkz-graph, the loop is placed with dir=SOEA south east

Picture

enter image description here

Code

\documentclass{article}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,thick]
\SetGraphUnit{3} 
\tikzset{VertexStyle/.style = {draw,circle,thick,
                               minimum size=1cm,
                               font=\Large\bfseries},thick} 
\Vertex{1} \SOWE(1){2} \SOEA(1){3} 
\Edges(3,2,1) \Edge(3)(1)

\Loop[dist=2cm,dir=NO,label=$0.6$,labelstyle=above](1)  
\Loop[dist=2cm,dir=SOEA,label=$0.8$,labelstyle=below right](3)  

\path[every node/.style={swap,auto}]    (2) to node {0.1} (1)
                                            to node {0.1} (3)
                                            to node {0.1} (2); 
\draw[->] (1) to [bend right] node [above left] {0.4} (2);
% it's possible with \Edge but Tikz's syntax is allowed too.
\end{tikzpicture} 
\end{document} 
8

If, like me, you want to add text above the loop created with Stefan Kottwitz's solution and you struggle doing so using \draw, here's what you could do using \path:

\path (3) edge [out=330,in=300,looseness=8] node[above] {0.8} (3);

You must log in to answer this question.

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