Graphviz:如何以圆形布局布置节点 [英] Graphviz: how to arrange nodes with circo layout
问题描述
我正在尝试绘制具有圆形拓扑的图形.
I'm trying to draw a graph with circle topology.
这是我期望看到的:
Here is what I'm expecting to see:
这是我的gv文件:
digraph g1 {
layout="circo";
node [shape = doublecircle]; N4 N6;
node [shape = circle];
N0 -> N1 [ label = "{1,0}"];
N1 -> N2 [ label = "{1,0}"];
N2 -> N3 [ label = "{1,0}"];
N3 -> N4 [ label = "{1,0}"];
N4 -> N5 [ label = "{1,0}"];
N5 -> N6 [ label = "{1,0}"];
N6 -> N0 [ label = "{1,0}"];
N0 -> N4 [ label = "{1,0}"];
N1 -> N5 [ label = "{1,0}"];
N2 -> N6 [ label = "{1,0}"];
N3 -> N0 [ label = "{1,0}"];
N4 -> N1 [ label = "{1,0}"];
N5 -> N2 [ label = "{1,0}"];
N6 -> N3 [ label = "{1,0}"];
}
这是上面图形的输出图像:
And here is an output image for graph above:
如何在graphviz中排列节点,使其看起来像 1 ?>
How can I arrange nodes in graphviz to make it look like 1?
推荐答案
如果目标是创建一个尊重节点顺序的图形,那就不是那么简单.您可以使用外部脚本计算节点的位置并使用neato渲染它.
If the goal is to have a graph which respects the order of the nodes, it's not that simple. You could calculate the position of the nodes with an external script and render it with neato.
或者您可以首先用仅确定节点正确顺序的边来布局节点:
Or you could first layout the nodes with the edges which determine the correct order of the nodes only:
digraph g1 {
node [shape = doublecircle]; N4 N6;
node [shape = circle];
edge[label="{1,0}"];
N0 -> N1 -> N2 -> N3 -> N4 -> N5 -> N6 -> N0;
}
具有:
circo graph.gv > tempgraph.gv
然后将其余边添加到tempgraph.gv
-只需在结束}
之前将以下内容复制粘贴:
Then add the remaining edges to tempgraph.gv
- just copy-paste the following before the closing }
:
N0 -> N4 [ label = "{1,0}"];
N1 -> N5 [ label = "{1,0}"];
N2 -> N6 [ label = "{1,0}"];
N3 -> N0 [ label = "{1,0}"];
N4 -> N1 [ label = "{1,0}"];
N5 -> N2 [ label = "{1,0}"];
N6 -> N3 [ label = "{1,0}"];
并使用neato
和-n
选项进行渲染:
And render it with neato
and the -n
option:
neato -n tempgraph.gv -Tpng -O
您可能希望微调标签的位置:
You may want to fine-tune the position of the labels:
这篇关于Graphviz:如何以圆形布局布置节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!