# Question RE DiscreteMarkovProcess Graph Labels

I'm trying to label the arc's of my Markov chain with symbols like $\alpha$, $\beta$, etc., to show how the Markov chain looks abstractly.

So, I did this...

    proc = DiscreteMarkovProcess[
1, {{1/2, 1/2, 0, 0, 0}, {1/2, 1/2, 0, 0, 0}, {0, 1/2, 1/2, 0,
0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1, 0}}];


And, then this (to try label the arcs)

     Graph[proc, EdgeLabels -> {1 <-> 2 -> "\[Alpha]"}]


and I'm getting an "error" - Nothing really happens.

   Graph[DiscreteMarkovProcess[
1, {{1/2, 1/2, 0, 0, 0}, {1/2, 1/2, 0, 0, 0}, {0, 1/2, 1/2, 0,
0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1, 0}}],
EdgeLabels -> {1 \[UndirectedEdge] 2 -> "\[Alpha]"}]


Any help would be much appreciated.

It seems that the DiscreteMarkovProcess has directed edges, so you need use the [DirectedEdge] version in your EdgeLabels specification. In version 10 the following works:

proc = DiscreteMarkovProcess[1,
{{1/2, 1/2, 0, 0, 0},
{1/2, 1/2, 0, 0, 0},
{0, 1/2, 1/2, 0, 0},
{0, 0, 0, 0, 1},
{0, 0, 0, 1, 0}}];
Graph[proc,
EdgeLabels -> {1 \[DirectedEdge] 2 -> Placed[Style["\[Alpha]", 12], {Right, "Middle"}]},
VertexSize -> 0.15]


(We can use smaller vertices to make the arrowheads visible.)

According to the comments below, this does not work in version 9. It is possible to extract the behavior of Edgelabels for DiscreteMarkovProcess, though, by fetching the options used to generate the default Graph of the discrete Markov process proc:

Options[Graph[proc]]


shows

EdgeLabels -> {4 \[DirectedEdge] 5 -> Placed[1, Tooltip],
2 \[DirectedEdge] 2 -> Placed[1/2, Tooltip],
2 \[DirectedEdge] 1 -> Placed[1/2, Tooltip],
3 \[DirectedEdge] 3 -> Placed[1/2, Tooltip], ...}


Note that Graph already has EdgeLabels defined for the DiscreteMarkovProcess as the transition probabilities placed as tooltips (both the comments below and the documentation seem to indicate that this is true in v9 as well as v10), so the syntax can be extracted and used to produce user-defined labels (although I can't provide the details, so this isn't really a v9 workaround).

• Awesome! Thanks. – PiE Apr 14 '15 at 2:11
• You know - I was mistaken - This does not work with my version of Mathematica - (version 9.0) - The graph is not labeled. – PiE Apr 14 '15 at 2:23
• No, it does not work - Bummer – PiE Apr 14 '15 at 3:51
• @Pierre, well, sorry I couldn't help. Best of luck! – Virgil Apr 14 '15 at 3:53
• @Pierre, if you check Options[Graph[proc]] (for the default graph of your process) you should be able to see the syntax used to generate any EdgeLabels that are present by default, and then you could just replace each label with what you want. – Virgil Apr 14 '15 at 4:02

This works for Mathematica 9.0 - The code above appears to work only for Mathematica 10.0.

 proc = DiscreteMarkovProcess[
1, {{1/2, 1/2, 0, 0, 0}, {1/2, 1/2, 0, 0, 0}, {0, 1/2, 1/2, 0,
0}, {0, 0, 0, 0, 1}, {0, 0, 0, 1, 0}}];
Graph[proc,
EdgeLabels -> {1 \[DirectedEdge] 2 -> Placed["\[Alpha]", .5],
1 \[DirectedEdge] 1 -> Placed["1-\[Alpha]", .5],
2 \[DirectedEdge] 1 -> Placed[Style["\[Beta]", 12], .5],
2 \[DirectedEdge] 2 -> Placed["1-\[Beta]", .5],
3 \[DirectedEdge] 3 -> Placed["c", .5],
3 \[DirectedEdge] 2 -> Placed["1-c", .45]}, VertexSize -> 0.15]