The DiscreteMarkovProcess defined in Mathematica can be passed to Graph to visualize it. It is exactly what I have done.


enter image description here

Which is almost fine except that I want to put characters from "A" to "U" instead of numbers from 1 to 21 inside the vertexes. I tried using

Graph[hmm, VertexLabels -> Thread[Range[21]->CharacterRange["A","U"]]]

This outputs enter image description here

I want the letters back into the center of vertexes, According to documentation I can use Placed, however doing

Graph[hmm, VertexLabels -> Placed[Thread[Range[21]->CharacterRange["A","U"]]],Center]

outputs enter image description here

How can I Fix this?

Additional Data:

You can create hmm using

p= Table[1/21//N,{21}];
tm = Table[If[j == i + 2, 0.9, If[j == i + 1, 0.1, 0]], {i, 1, 21}, {j, 1, 21}];
hmm = DiscreteMarkovProcess[p,tm];
  • 1
    $\begingroup$ Graph[hmm, VertexLabels -> Thread[Range[ 21] -> (Placed[#, Center] & /@ CharacterRange["A", "U"])]] is your after?Could I vote to colse it as a mistake? $\endgroup$ – yode May 1 '17 at 14:32
  • $\begingroup$ Yes, thank you. I see now the that the issue was that Placed is not Listable? Then why would something like VertexLables->Placed["Name",Center] work? Also how could I understand the black thingines inside the graph of my version? I'd appreciate it if you post explanations to those questions as well as your solution as an asnwer. $\endgroup$ – Vahagn Tumanyan May 1 '17 at 14:34
  VertexLabels -> Table[i -> Placed[ToUpperCase[Alphabet[]][[i]], Center], {i, 21}],
  GraphLayout -> "SpringEmbedding",
  ImageSize -> Large]




VertexReplace[Graph[hmm, GraphLayout -> {"LayeredEmbedding", "Orientation" -> Left}],
 Thread[Range@21 -> CharacterRange["A", "U"]]]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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