English 中文(简体)
How to add edge labels in Graphviz?
原标题:
  • 时间:2009-11-27 05:08:53
  •  标签:
  • graphviz
  • dot

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.

alt text

问题回答

@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: example of a label with tooltip

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"]

enter image description here

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

For Example:

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




相关问题
graphviz: minor tweaks to make the graph look nicer

I have a test graph here that I would like to tweak to make it look nicer. Here is the graphviz (dot) source, test6.dot: digraph G { ranksep=0.3; size="6.0,6.0"; node [fontsize=11]; ...

GraphViz - How to connect subgraphs?

In the DOT language for GraphViz, I m trying to represent a dependency diagram. I need to be able to have nodes inside a container and to be able to make nodes and/or containers dependent on other ...

QuickGraph GraphvizRecord doesn t display in vertices

I m trying to build a Graphviz graph containing record vertices using QuickGraph. So far, I have this: var algo = new GraphvizAlgorithm<Entity, EntityEdge>(this); algo.CommonVertexFormat.Shape =...

Specified edge lengths on networkx/igraph (Python)

I wanted to visualize a network with the data I have and would like to graph them with specific edge lengths. I use Python, and I ve tried networkx and igraph to plot but all seem to assign fixed edge ...

Graphical interface for Graphiz for Mac OS?

I installed the Graphviz GUI from pizelmap.com, but it appears to only be a viewer for .dot Graphviz files. I am looking for a graphical editor, where I can create diagrams by pointing and clicking--...

How to add edge labels 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?

Tips on Using Bison --graph=[file] on Linux

Recently (about a month ago) I was trying to introduce new constructs to my company s in-house extension language, and struggling with a couple of reduce-reduce errors. While I eventually solved this ...

How to change arrowhead type?

I want to simulate non-directional graphs with .dot. To that end, I want the arrowhead type to be "none". How do I set this? "f" -> "t" [label=2],[arrowhead=none] "m" -> "d" [label=0],[...

热门标签