Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 (s a tooltip).

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
great answer - appreciate the conciseness and the extra tidbit at the end on PropertyList. – Paul_A Oct 14 at 3:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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