Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GraphViz edge labels

I'm trying to draw a graph of the dependencies between C header files using graphviz.

Basically, what I'm doing is log all the #include that appear and the condition (#if conditions I mean). If a file includes another one, it becomes its father in the graph and the potential condition is the edge label.

I obtain a pretty large graph. The problem stems from the edge labels which are always horizontal (you cannot change that) and always seem to be left-align (I've tried labelloc and labeljust but it doesn't change anything. What is the correct way to "center" the label of one edge.

To avoid this problem, I've tried to render conditions as nodes. If A.h includes B.h under ANSI condition, there's a link from A.h to ANSI and then from ANSI to B.h... That looks ok, but the problem is that if C.h include D.h under the same condition, I would see a link from A.h to ANSI, one from to C.h to ANSI; one from ANSI to B.h and one from ANSI to D.h . The problem is I don't know if it's A.h or C.h that includes B.h . Is there a way to specify something like go through nodes (a link from A.h to B.h that goes under ANSI maybe leveraging transparency.)

like image 883
LB40 Avatar asked May 06 '09 17:05

LB40


People also ask

What is rank in Graphviz?

Ranks and Subgraphs To work out the layout, Graphviz uses a system it calls "ranks". Each node is assigned a higher rank than the highest ranked node that point to it. If your rank direction is set to left to right ( rankdir=LR ), then nodes with a higher rank are placed further to the right.

What is Graphviz Neato?

neato is a reasonable default tool to use for undirected graphs that aren't too large (about 100 nodes), when you don't know anything else about the graph. neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.

What language does Graphviz use?

Abstract grammar for defining Graphviz nodes, edges, graphs, subgraphs, and clusters. Terminals are shown in bold font and nonterminals in italics. Literal characters are given in single quotes.

What is the shape of a node?

Shape nodes Holds an object's geometry attributes or attributes other than the object's transform node attributes. A shape node is the child of a transform node. A transform node has only one shape node.


1 Answers

labelloc and labeljust are meaningless for edges. See here, it says "GC" as Graph, Cluster or "N" as Node, respectively.

You could, however, consider generating unique nodes for each condition with labels. Then there would be multiple nodes with different "dot ID's", but a same label (condition's text), so it would be clear if it was A.h or C.h that incuded B.h. I think You will be pleased with the results, as You already stated that it looks ok.

Good luck!

like image 63
Paweł Polewicz Avatar answered Sep 23 '22 10:09

Paweł Polewicz