TransWikia.com

How to label edges of Continuous Markov Process

Mathematica Asked on July 2, 2021

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.

One Answer

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

Correct answer by kglr on July 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP