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.
Best Answer
There is a
\Loop
command for this, see the example on page 25 of the manual.The syntax is
without any spaces before/after brackets/parens.
In the options one can specify
dir
- the possible values areWE
,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