开发者

How to add edge labels in Graphviz?

开发者 https://www.devze.com 2022-12-12 11:01 出处:网络
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.

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?


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.

How to add edge labels in Graphviz?


@Andrew Walker has given a great answer!

It's also worth being aware of the labeltooltip attribute. This allows an additional string to be attached to the label of an edge. This is easier for a user than the tooltip attribute, as it can be fiddly to hover directly on an edge. The syntax is as follows:

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

Which gives the following result:

How to add edge labels in Graphviz?


Landed here by googling whether labels could be on arrow's ends, for UML's composition/aggregation. The answer is yes:

"Person" -> "Hand" [headlabel="*", taillabel="1"]

How to add edge labels in Graphviz?


You can use label="\E" It will generate bye default label.

For Example:

digraph G {
 a -> b [ label="\E" ];
 b -> c [ label="\E"];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消