[英]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: 这是我期待看到的:
Here is my gv file: 这是我的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: 这是上图的输出图像:
How can I arrange nodes in graphviz to make it look like 1 ? 如何在graphviz中安排节点使其看起来像1 ?
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 .
您可以使用外部脚本计算节点的位置,并使用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;
}
with: 有:
circo graph.gv > tempgraph.gv
Then add the remaining edges to tempgraph.gv
- just copy-paste the following before the closing }
: 然后将剩余的边添加到
tempgraph.gv
- 只需在结束前复制粘贴以下内容}
:
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 render it with neato
and the -n
option: 并使用
neato
和-n
选项呈现它:
neato -n tempgraph.gv -Tpng -O
You may want to fine-tune the position of the labels: 您可能需要微调标签的位置:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.