How to add edge labels in Graphviz?

前端 未结 4 854
耶瑟儿~
耶瑟儿~ 2020-12-12 15:17

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?

4条回答
  •  抹茶落季
    2020-12-12 16:07

    @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:

提交回复
热议问题