且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Graphviz:安排节点

更新时间:2023-01-28 13:17:00

rank = same 和不可见的边缘是您的朋友:

rank=same in conjunction with invisible edges are your friend:

digraph Test 
{
    nodesep = 0.5;                 // even node distribution
    node [ shape = circle, width = 0.7 ];
    edge [ style = invis ];

    { rank = same; A; B; C; D; E }
    { rank = same; F; G; H; I; J }
    { rank = same; K; L; M; N; O }
    { rank = same; P; Q; R; S; T }
    { rank = same; U; V; W; X; Y }

    C -> { F G H I J } 
    H -> { K L M N O }
    M -> { P Q R S T }
    R -> { U V W X Y }
}

代替最后四行,您只需使用

Instead of the last four lines, you could simply use

A -> F -> K -> P -> U;

对于给定的节点,这将导致相同的结果,但是当节点大小变化时,稳定性可能会降低.

This would lead to the same result with the given nodes but may be less stable when node sizes are varying.