如何对齐节点列和包边?

How to align columns of nodes and wrap edges?

我可以使用这段代码生成图表:

文件test.dot:

digraph g {
    {rank=same;  1 -> 2 -> 3 -> 4}
    {rank=same;  5 -> 6 -> 7 -> 8}
    {rank=same;  9 -> 10 -> 11 -> 12}

    4 -> 5
    8 -> 9
}

dot test.dot -Tpng -o test.png

输出:

但是,我希望节点的排列更像这样:

是否可以在 graphviz dot 中制作这样形状的图表?

使用权重较大的隐形边:

digraph g 
{
    splines="ortho"
    
    // connect the left most nodes and keep them one below the other
    1 -> 5 -> 9[ style = invis, weight = 10 ];

    // do your stuff
    { rank = same;  1 -> 2 -> 3 -> 4 }
    { rank = same;  5 -> 6 -> 7 -> 8 }
    { rank = same;  9 -> 10 -> 11 -> 12 }

    4 -> 5;
    8 -> 9;
}

产量: