How to add edge labels in Graphviz?

user855 picture user855 · Nov 27, 2009 · Viewed 75.9k times · Source

I am trying to draw a graph using Graphviz, but I need to add labels on the edges. There does not seem to be any way to that in Graphviz. Are there a way out?

Answer

Andrew Walker picture Andrew Walker · Nov 27, 2009

You use the label property attached to the edge.

digraph G {
 a -> b [ label="a to b" ];
 b -> c [ label="another label"];
}

The above generates a graph that looks something like this.

alt text