# How do you make a tkz graph with edges starting and ending at the same vertex?

I am trying to use the tkz-graph package to put together a directed graph. I have never used it before, so I am trying to piece together examples I have found on the internet. Below is the code that I have so far:

\begin{tikzpicture}
\SetUpEdge[lw = 1.5pt, color = blue]
\GraphInit[vstyle=Normal]
\SetGraphUnit{4}
\tikzset{VertexStyle/.append  style={fill}}
\Vertex{S}
\EA(S){I} \EA(I){R}
\tikzset{EdgeStyle/.style={->}}
\Edge[label=$\beta$](I)(R)
\Edge[label=$\alpha$](S)(I)
\end{tikzpicture}


This gives me a graph with three vertices, and two edges. I want to also add in a loop, starting and ending at the same vertex, for each vertex. I tried including the following three lines:

\Edge[label=$1-\alpha$](S)(S)
\Edge[label=$1-\beta$](I)(I)
\Edge[label=$1$](R)(R)


But this didn't work. The graph just came out looking messy. I also tried to fiddling with the angle of the edges, by doing the following:

\tikzset{EdgeStyle/.style={->}, in=45, out=135}
\Edge[label=$1-\alpha$](S)(S)
\Edge[label=$1-\beta$](I)(I)
\Edge[label=$1$](R)(R)


But it still looked messy. I just want those edges to look like loops, with labels on them, as shown in the code. Any help would be appreciated.

• It will always attract more help if you post an MWE, such that potential commentators don't have to invent prembles etc. Aug 8 '13 at 11:22
• I'd really like to help you, but the whole documentation for tkz-graph is in french. Does anybody know, if there is an english version? Aug 8 '13 at 12:07
• @HenriMenke I don't think Alain has written an English manual, but there are plenty of examples in the manual, so you can learn something from it. Aug 8 '13 at 12:36

There is a \Loop command for this, see the example on page 25 of the manual.

The syntax is

\Loop[<options>](<vertex>)


without any spaces before/after brackets/parens.

In the options one can specify

• dir - the possible values are WE, EA, NO, SO, NOWE, NOEA, SOWE, SOEA for west, east, north, south, north west etc., e.g. dir=NO.
• dist - defines the size of the loop. Specify a length, e.g. dist=2cm.
• label - the label of the vertex, e.g. label={$a$}
• style - the style of the loop, allowing you to customize thickness, color etc., e.g. style={green,->,thick}
• labelstyle - the style of the label, allowing you to customize positioning, colour etc., e.g. labelstyle={above} to place the label above the loop.

## Example

\documentclass[convert]{standalone}
\usepackage{tkz-graph}
\begin{document}
\begin{tikzpicture}
\SetUpEdge[lw = 1.5pt, color = blue]
\GraphInit[vstyle=Normal]
\SetGraphUnit{4}
\tikzset{VertexStyle/.append  style={fill}}
\Vertex{S}
\EA(S){I} \EA(I){R}
\tikzset{EdgeStyle/.style={->}}
\Edge[label=$\beta$](I)(R)
\Edge[label=$\alpha$](S)(I)
\Loop[dir=NO,label={$1-\beta$},labelstyle={above}](I)
\Loop[dir=SO,dist=1cm](R)
\Loop[dir=WE,dist=2cm,style={blue,very thick},label={$1-\alpha$},labelstyle={fill=white}](S)
\end{tikzpicture}
\end{document}