How to insert mathematical symbols like Greek characters in a Graphviz dot file?

maths-help-seeker picture maths-help-seeker · Mar 13, 2012 · Viewed 8.8k times · Source

I have an unique problem. I am using dot to represent a graph which is generic in nature. So, instead of using numbers, I was planning to use symbols like greek letters like alpha, beta, etc. I am curious to know how can we label nodes/edges in .dot file using some symbols?

for example,

node1 -> node2 [label= <something here which will show up as symbol of beta> style=dashed]

Answer

dgw picture dgw · Mar 13, 2012

You can use HTML-like a labels:

digraph G {
  a [ label=<&#945;>]
  b [ label=<&#946;>]
  c [ label=<&#947;>]

  a -> b -> c
}

will show alpha -> beta -> gamma:

enter image description here

You could also used named HTML references to make it even clearer (mentioned in a comment):

label=<I love &alpha; and &beta;>

The surrounding <> indicate that the label should be parsed as a custom language that looks like an HTML subset: http://www.graphviz.org/doc/info/lang.html#html