Graphviz:如何使用circo布局排列节点

Fil*_*ipp 12 graphviz

我正在尝试使用圆形拓扑绘制图形.

这是我期待看到的: 在此输入图像描述

这是我的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}"];    
}
Run Code Online (Sandbox Code Playgroud)

这是上图的输出图像: 在此输入图像描述

如何在graphviz中安排节点使其看起来像1

mar*_*pet 10

如果目标是拥有一个尊重节点顺序的图形,那就不那么简单了.您可以使用外部脚本计算节点的位置,并使用neato进行渲染.

或者您可以首先使用边来布局节点,这些边仅确定节点的正确顺序:

digraph g1 {
    node [shape = doublecircle]; N4 N6;
    node [shape = circle];
    edge[label="{1,0}"];
    N0 -> N1 -> N2 -> N3 -> N4 -> N5 -> N6 -> N0;
}
Run Code Online (Sandbox Code Playgroud)

有:

circo graph.gv > tempgraph.gv
Run Code Online (Sandbox Code Playgroud)

然后将剩余边添加到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}"];
Run Code Online (Sandbox Code Playgroud)

并使用neato-n选项呈现它:

neato -n tempgraph.gv -Tpng -O
Run Code Online (Sandbox Code Playgroud)

您可能需要微调标签的位置:

circo布局