Graphviz:Python中的edge-to-record标签(gv)

2024-04-20 05:57:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难生成以下边缘:

...
h1 -> "h2":f2;

如本例所示:datastruct

考虑以下Python代码:

^{pr2}$

它在执行后给出以下输出:

digraph g {
    node [label="\N"];
    graph [rankdir=LR];
    h1 [shape=record];
    h2 [label="<f1> s1 | <f2> s2", shape=record];
    h1 -> h2;
}

这就给我留下了一个问题:如何获得上面显示的边,以便它指向正确的记录条目。在

提前谢谢。在


Tags: 代码nodeh2recordh1label边缘graph
1条回答
网友
1楼 · 发布于 2024-04-20 05:57:05

要执行此操作,需要设置头部端口:

我只在C语言中完成了这项工作,但根据您在python中所展示的内容,我假设如下所示:

e = gv.edge(n1, n2)
gv.setv(e, "headport", "f1") # or another key from the records

这将创建如下边:

^{pr2}$

如果需要指向相反方向,也可以设置尾门。在

相关问题 更多 >