GraphViz 边标签

发布于 2024-07-19 05:19:37 字数 499 浏览 11 评论 0原文

我正在尝试使用 graphviz 绘制 C 头文件之间的依赖关系图。

基本上,我正在做的是记录所有出现的#include 和条件(我的意思是#if 条件)。 如果一个文件包含另一个文件,则该文件将成为图中的父文件,并且潜在条件是边标签。

我得到了一个相当大的图表。 问题源于边缘标签始终是水平的(您无法更改它)并且似乎总是左对齐(我尝试过 labelloc 和 labeljust 但它不会改变任何内容。“居中”的正确方法是什么 但是

为了避免这个问题,我尝试将条件渲染为节点。如果 Ah 在 ANSI 条件下包含 Bh,则存在从 Ah 到 ANSI,然后从 ANSI 到 Bh 的链接。看起来不错, 问题是,如果 Ch 在相同条件下包含 Dh ,我会看到一个从 Ah 到 ANSI 的链接,一个从 Ch 到 ANSI 的链接;一个从 ANSI 到 Bh 的链接,一个从 ANSI 到 Dh 的链接。它是 Ah 或 Ch 包含 Bh 。有没有办法指定诸如遍历节点之类的内容(从 Ah 到 Bh 的链接可能会利用透明度。)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

灼疼热情 2024-07-26 05:19:37

labelloc 和 labeljust 对于边缘来说没有意义。 请参阅此处,它表示“GC”为图、集群或“N”分别作为节点。

但是,您可以考虑为每个条件生成带有标签的唯一节点。 那么就会有多个节点具有不同的“点 ID”,但具有相同的标签(条件的文本),因此很清楚包含 AhCh 的 <代码>Bh。 我想您会对结果感到满意,因为您已经说过它看起来不错。

祝你好运!

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!

落花随流水 2024-07-26 05:19:37

我使用具有相同标签的独特节点取得了很多成功,具体取决于我所说明的内容。 根据需要获得边缘标签居中的错觉的一种有趣方法是使用 shape=plaintext 的节点。

您还可以使用它来提供连接点 - 有许多通往或来自明文节点的边,如下所示:

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

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"
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文