英文:
Graphviz edges with ortho lines not aligning with ports
问题
我正在尝试创建一个具有双向箭头的Graphviz块图。我使用了从Python Graphviz包创建的Graphviz代码。在探索边缘选项后,我喜欢正交边缘,但当我编写正交边缘时,边缘未正确连接到端口,并且标签根本不与边缘对齐。我该如何修复这个问题。非常感谢您提前的帮助:D
以下是您提供的Graphviz代码,Python后端生成的:
digraph {
graph [nodesep=.3 rankdir=LR ranksep=2 splines=ortho]
node [shape=record]
Node1 [label="{{Node1}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node2 [label="{<p0>B|{Node2}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node3 [label="{<p0>B|{Node3}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node4 [label="{<p0>B|{Node4}}" fontsize=25 width=3]
Node5 [label="{<p0>B|{Node5}}" fontsize=25 width=3]
Node6 [label="{<p0>B|{Node6}}" fontsize=25 width=3]
Node7 [label="{<p0>B|{Node7}}" fontsize=25 width=3]
Node8 [label="{<p0>B|{Node8}}" fontsize=25 width=3]
Node9 [label="{<p0>B|{Node9}}" fontsize=25 width=3]
Node10 [label="{<p0>B|{Node10}}" fontsize=25 width=3]
Node1:<f0> -> Node2:<p0>
Node1:<f1> -> Node3:<p0>
Node1:<f2> -> Node4:<p0>
Node2:<f0> -> Node5:<p0>
Node2:<f1> -> Node6:<p0>
Node2:<f2> -> Node7:<p0>
Node2:<p0> -> Node1:<f0>
Node3:<f0> -> Node8:<p0>
Node3:<f1> -> Node9:<p0>
Node3:<f2> -> Node10:<p0>
Node3:<p0> -> Node1:<f1>
Node4:<p0> -> Node1:<f2>
Node5:<p0> -> Node2:<f0>
Node6:<p0> -> Node2:<f1>
Node7:<p0> -> Node2:<f2>
Node8:<p0> -> Node3:<f0>
Node9:<p0> -> Node3:<f1>
Node10:<p0> -> Node3:<f2>
}
这是Python后端生成的Graphviz代码。在使用直线时生成的图如下,它表示正确,但我想使用正交边缘而不是直线:
这是使用直线生成的图。
英文:
I am trying to create a graphviz block diagram with bidirectional arrows. I have used this graphviz code created from python graphviz package. After exploring the edge options, I liked ortho edges but when I code that, the edges are not getting connected to ports properly and the labels are not at all aligned to the edges. What can I do to fix this. Thanks a lot in advance
digraph {
graph [nodesep=.3 rankdir=LR ranksep=2 splines=ortho]
node [shape=record]
Node1 [label="{{Node1}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node2 [label="{<p0>B|{Node2}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node3 [label="{<p0>B|{Node3}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node4 [label="{<p0>B|{Node4}}" fontsize=25 width=3]
Node5 [label="{<p0>B|{Node5}}" fontsize=25 width=3]
Node6 [label="{<p0>B|{Node6}}" fontsize=25 width=3]
Node7 [label="{<p0>B|{Node7}}" fontsize=25 width=3]
Node8 [label="{<p0>B|{Node8}}" fontsize=25 width=3]
Node9 [label="{<p0>B|{Node9}}" fontsize=25 width=3]
Node10 [label="{<p0>B|{Node10}}" fontsize=25 width=3]
Node1:<f0> -> Node2:<p0>
Node1:<f1> -> Node3:<p0>
Node1:<f2> -> Node4:<p0>
Node2:<f0> -> Node5:<p0>
Node2:<f1> -> Node6:<p0>
Node2:<f2> -> Node7:<p0>
Node2:<p0> -> Node1:<f0>
Node3:<f0> -> Node8:<p0>
Node3:<f1> -> Node9:<p0>
Node3:<f2> -> Node10:<p0>
Node3:<p0> -> Node1:<f1>
Node4:<p0> -> Node1:<f2>
Node5:<p0> -> Node2:<f0>
Node6:<p0> -> Node2:<f1>
Node7:<p0> -> Node2:<f2>
Node8:<p0> -> Node3:<f0>
Node9:<p0> -> Node3:<f1>
Node10:<p0> -> Node3:<f2>
}
This is the graphviz code that python backend generated.
This is what generated when using lines. It represents correctly but I would like to have ortho edges rather than line
答案1
得分: 2
对于 splines=ortho
,你不应该使用边缘的标签规范,所以你可以用 Node1 -> Node2
替代 Node1:<f0> -> Node2:<p0>
。
英文:
For splines=ortho
you should not use the label specifiers for the edges, so instead of Node1:<f0> -> Node2:<p0>
you can just use Node1 -> Node2
.
digraph {
graph [nodesep=.3 rankdir=LR ranksep=2 splines=ortho]
node [shape=record]
Node1 [label="{{Node1}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node2 [label="{<p0>B|{Node2}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node3 [label="{<p0>B|{Node3}|{<f0>A|<f1>A|<f2>A}}" fontsize=25 width=3]
Node4 [label="{<p0>B|{Node4}}" fontsize=25 width=3]
Node5 [label="{<p0>B|{Node5}}" fontsize=25 width=3]
Node6 [label="{<p0>B|{Node6}}" fontsize=25 width=3]
Node7 [label="{<p0>B|{Node7}}" fontsize=25 width=3]
Node8 [label="{<p0>B|{Node8}}" fontsize=25 width=3]
Node9 [label="{<p0>B|{Node9}}" fontsize=25 width=3]
Node10 [label="{<p0>B|{Node10}}" fontsize=25 width=3]
Node1 -> Node2
Node1 -> Node3
Node1 -> Node4
Node2 -> Node5
Node2 -> Node6
Node2 -> Node7
Node2 -> Node1
Node3 -> Node8
Node3 -> Node9
Node3 -> Node10
Node3 -> Node1
Node4 -> Node1
Node5 -> Node2
Node6 -> Node2
Node7 -> Node2
Node8 -> Node3
Node9 -> Node3
Node10 -> Node3
}
Result:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论