\section{Probabilistic graphs}
%<-------------------------------------------------------------------------->
A probabilistic graph (the graph of a Markov chain) is a weighted directed
graph: the weight of the edge $i\to j$ is the probability of going from the
state $i$ to the state $j$.

\subsection{Any number of states: \tkzcname{grProbMatrix}}
\begin{NewMacroBox}{grProbMatrix}{\oarg{local options}\var{list of states}\var{transition matrix}}
\emph{The graph of the transition matrix: \tkzcname{tkzGraphFromMatrix}
with the options \tkzname{directed} and \tkzname{weighted}. The other
options are those of \tkzcname{tkzGraphFromMatrix}. The pairs
$i\to j$, $j\to i$ are bent and the loops are directed away from the
center.}
\end{NewMacroBox}

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \grProbMatrix[unit=2,rotation=90]{A,B,C}%
    {0.5,0.3,0.2;
     0.1,0.6,0.3;
     0.4,0,0.6}
\end{tikzpicture}
\end{tkzexample}

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \SetVertexMath
  \grProbMatrix[unit=2.2,rotation=45]%
    {E_1,E_2,E_3,E_4}%
    {0.2,0.8,0,0;
     0,0.5,0.5,0;
     0,0,0.3,0.7;
     1,0,0,0}
\end{tikzpicture}
\end{tkzexample}

\newpage
\subsection{Two states: \tkzcname{grProb}}
\begin{NewMacroBox}{grProb}{\oarg{local options}\var{left}\var{right}\var{N}\var{S}\var{W}\var{E}}
\begin{tabular}{llc}
\toprule
Arguments   &  & Definition              \\
\midrule
\TAline{left}  {}{name of the vertex on the left}
\TAline{right} {}{name of the vertex on the right}
\TAline{N}     {}{label of the top edge (left to right)}
\TAline{S}     {}{label of the bottom edge (right to left)}
\TAline{W}     {}{label of the loop on the left}
\TAline{E}     {}{label of the loop on the right}
\bottomrule
\end{tabular}

\medskip
\begin{tabular}{llc}
\toprule
Options & Default & Definition                              \\
\midrule
\TOline{unit}      {4}   {distance between the vertices}
\TOline{LposA}     {180} {angle of an outside label of the left vertex}
\TOline{LposB}     {0}   {angle of an outside label of the right vertex}
\TOline{Ldist}     {0cm} {distance between a node and its label}
\TOline{LoopDist}  {4cm} {size of the loops}
\bottomrule
\end{tabular}

\medskip
\emph{The labels of the edges are written in math mode. The vertices are
named \tkzname{grA} and \tkzname{grB}.}
\end{NewMacroBox}

\begin{tkzexample}[vbox,small]
\begin{tikzpicture}
  \useasboundingbox (-2.5,-2) rectangle (7.5,2);
  \grProb{A}{B}{0.3}{0.4}{0.7}{0.6}
\end{tikzpicture}
\end{tkzexample}

\begin{tkzexample}[vbox,small]
\begin{tikzpicture}
  \useasboundingbox (-2.5,-2.5) rectangle (7.5,2.5);
  \tikzset{VertexStyle/.style = {shape = circle,
      shading = ball, ball color = orange,
      minimum size = 20pt, draw, color = white}}
  \tikzset{LabelStyle/.style = {draw,color=orange,fill=white}}
  \tikzset{EdgeStyle/.style = {->, thick,
      double = orange, double distance = 1pt}}
  \grProb[Ldist=0.1cm,LposA=0,LposB=180]{Paris}{Lyon}%
     {\frac{2}{3}}{\frac{3}{4}}{\frac{1}{3}}{\frac{1}{4}}
\end{tikzpicture}
\end{tkzexample}

\subsection{Three states: \tkzcname{grProbThree}}
\begin{NewMacroBox}{grProbThree}{\oarg{local options}\var{A}\var{B}\var{C}\var{aa/ab/ac}\var{bb/ba/bc}\var{cc/ca/cb}}
\emph{The three states are placed on a circle and named \tkzname{grA},
\tkzname{grB}, \tkzname{grC}; the arguments 4 to 6 give the labels of the
loop and of the two edges leaving each state. Same options as
\tkzcname{grProb}. \tkzcname{grProbMatrix} is now simpler for this case.}
\end{NewMacroBox}

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=.75]
  \tikzset{LabelStyle/.style = {draw,fill=white}}
  \grProbThree[unit=4]{A}{B}{C}%
     {0.1/0.3/0.6}{0.2/0.3/0.5}{0.25/0.35/0.4}
\end{tikzpicture}
\end{tkzexample}

\endinput
