1

这是我在通过 pygraphviz 与 dot 交互时偶然发现的一个问题。我正在通过标签创建记录,但我想知道如何连接记录中的端口而不是记录节点本身。

在点它应该看起来像这样:

a00 [shape = "record" label="{{RecordThing1}|{<1>A|<2>B|<3>C|<4>D|<5>E|<6>F}}"];
a01 [shape = "record" label="{{RecordThing2}|{<1>A|<2>B|<3>C|<4>D|<5>E|<6>F}}"];
a00:1 -> a01:1
4

2 回答 2

1

找到解决方案:可以使用边的headport和属性。tailport例如

agraph.add_node('a00', 'a01', tailport=1, headport=1)

阅读更多内容:例如https://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:headport

于 2016-08-15T00:49:56.183 回答
0

tortal贴出的解决方案代码有一个小错误:需要使用add_edge(而不是add_node)。

假设两个结构 'a00' 和 'a01' 具有字段 'f0'、'f1' 和 'f2','tailport' 和 'headport' 边缘属性确实可以用于链接不同的字段

例如,用于链接 a00:f1 和 a01:f0

from pygraphviz import AGraph
g = AGraph()
g.add_node("a00", label="<f0> text | {<f1> text | <f2> text}", shape="record")
g.add_node("a01", label="<f0> text | {<f1> text | <f2> text}", shape="record")
g.add_edge('a00', 'a01', tailport='f1', headport='f0')
于 2020-06-03T09:20:17.463 回答