How do I get Graph to display the transition probabilities for a Markov process as labels on the graph's edges? The information is clearly present in the graph, but only displays when I hover over the edges. Is there a way to get the information to display as edge labels (without going through complex machinations)?

For example,

mp = DiscreteMarkovProcess[{1, 0, 0}, ({
     {0.6, 0.1, 0.3},
     {0.2, 0.7, 0.1},
     {0.3, 0.3, 0.4}


with no labeling of edges, even though I can hover over any edge to see the associated transition probability (as a tooltip).


2 Answers 2


You can extract the probabilities from the properties of the edges and assign them as edge labels using

g = Graph[mp];
Scan[(PropertyValue[{g, #}, EdgeLabels] = PropertyValue[{g, #}, "Probability"]) &,


enter image description here

You can find this (and other) properties using the PropertyList function:

PropertyList[{g, 1 \[DirectedEdge] 2}]

(* {"Probability", EdgeLabels, EdgeShapeFunction, EdgeStyle} *)

From here, I used PropertyValue to set the properties. I imagine there are a few other (and possibly better/simpler) ways to accomplish this.

  • $\begingroup$ great answer - appreciate the conciseness and the extra tidbit at the end on PropertyList. $\endgroup$
    – Paul_A
    Oct 14, 2015 at 3:18

You can use MarkovProcessProperties[mp, "TransitionMatrix"] as edge labels directly in Graph:

mp = DiscreteMarkovProcess[{1, 0, 0}, {{.6, .1, .3}, {.2, .7, .1}, {.3, .3, .4}}];

  EdgeLabels -> {e_ :> 
    MarkovProcessProperties[mp, "TransitionMatrix"][[## & @@ e]]}]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.