views:

1388

answers:

2

Hi...

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-aligh (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...)...

Hope it's clear

+3  A: 

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!

Reef
thanks for the answer...that seems to be a good idea...i'll try this
LB
+2  A: 

I have had a lot of success using unique nodes with the same label, depending on what I'm illustrating. An interesting way to get the illusion of an edge label centred as you require is to use a node with shape=plaintext.

You can use that also to provide a join point - have a number of edges going to or from the plaintext node as shown below:

digraph joins {

node [shape=box weight=bold fontsize=18 color=black fontcolor=black]
edge [color=black fontcolor=black ]
graph[size="6,4",ratio=fill,center=1]

tblXXMaster[shape=record label="tblXXMaster | <f0>intMasterXXNumber | <f1>boolXXsPrinting"] 
set[shape=plaintext label="sets flag"]
setandclear[shape=plaintext label="sets next value\nand clears flag"]
setandclear->tblXXMaster:f0
setandclear->tblXXMaster:f1

set->tblXXMaster:f1
use[shape=plaintext label="uses current\nnumber"]
tblXXMaster:f0->use
XX[shape=plaintext label="XXs\nflag"]
tblXXMaster:f1->XX

"wndManualReceipt\n.procOne"->setandclear
"wndManualDebit\n.procOne"->setandclear
"wndApproveXXs\n.procOne\n.d005TempSetBitToZero"->setandclear
"wndPrintXXs\n.procZero\n.procOne"->setandclear
"wndUnapproveXXs\n.procZero\n.procOne"->setandclear
"wndWriteXXForMultipleInvoices\n.procOne\n.d005TempSetBitToZero"->setandclear
"wndWriteManualXX\n.procOne\n.procZero"->setandclear

"wndConfirmXXPrint\n.applyLock"->set
"wndConfirmMultiInvoiceXXPrint\n.applyLock"->set

use->"wndConfirmXXPrint\n.nextNumber"
use->"wndConfirmManualXXPrint\n.nextNumber"
use->"wndConfirmMultiInvoiceXXPrint\n.nextNumber"
XX->"wndConfirmManualXXPrint\n.doPrint"
XX->"wndConfirmMultiInvoiceXXPrint\n.doPrint"
}
Andy Dent
the problem is that i have a relation relation ship. If a.c includes a.h if i have CONFIG_X and b.c includes b.h with the same CONFIG_X...I would have one link from a.c to CONFIG_X, one from b.c to CONFIG_X and two links from CONFIG_X to a.h and b.h ...by looking at the graph how do i know if this is a.c or b.c that includes a.h and b.h ?
LB
In this case I would either just use the CONFIG_X as the includes label on the edge from a.c to a.h OR if you are using the plaintext approach, have two plaintext nodes CONFIG_X_A and CONFIG_X_B both with label="CONFIG_X".
Andy Dent