3
$\begingroup$

I can label a DiscreteMarkovProcess

P = {{0, 1/4, 1/2, 1/4, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1/3, 0, 2/3,
     0}, {0, 0, 0, 0, 0, 1},
   {0, 0, 1/4, 0, 3/4, 0}, {1/4, 0, 0, 0, 3/4, 0}};
proc = DiscreteMarkovProcess[1, P];
 Graph[proc, EdgeLabels -> {DirectedEdge[i_, j_] :> P[[i, j]]}]

but how to label a ContinuousMarkovProcess (without using its discrete version) For example

P = {{-7, 2, 5, 0}, {0, -5, 0, 5}, {0, 0, -2, 2}, {0, 0, 0, 0}};
pr = ContinuousMarkovProcess[{1, 0, 0, 0}, P];
g = Graph[pr, EdgeLabels -> {DirectedEdge[i_, j_] :> P[[i, j]]}]

does not work. Inspired by the discrete answer How do I show the transition probabilities in a graph of a Markov process? I tried

PropertyList[{g, 1 \[DirectedEdge] 2}]
Scan[(PropertyValue[{g, #}, EdgeLabels] = 
    PropertyValue[{g, #}, "TransitionRate"]) &, EdgeList[g]]

but it does not work.

$\endgroup$

1 Answer 1

4
$\begingroup$

Looks like Automatic EdgeStyle settings over-ride the user-specified EdgeStyle settings when the first argument of Graph is a ContinuousMarkovProcess.

gcmp = Graph @ pr;

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

1. A work-around: We can re-set AnnotationValue[gcmp, EdgeLabels] and replace Tooltip with `Center:

AnnotationValue[gcmp, EdgeLabels] = 
  AnnotationValue[gcmp, EdgeLabels] /. Tooltip -> Center;

gcmp 

enter image description here

2. Another simple work-around: add the option GraphStyle -> {}:

Graph[pr, GraphStyle -> {},  
 EdgeLabels -> {DirectedEdge[i_, j_] :> P[[i, j]]}]

enter image description here

Graph[pr, GraphStyle -> {}, 
  EdgeLabels -> {DirectedEdge[i_, j_] :> 
     MarkovProcessProperties[pr, "TransitionMatrix"][[i, j]]}] 

enter image description here

$\endgroup$

Your Answer

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

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