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.)
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.
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.
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.
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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With