2017-10-03 18 views
1

私は、グラフを生成するには、このコードを使用することができます:ノードとラップエッジの列を揃える方法は?

ファイル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

を出力:

enter image description here

しかし、私はノードのランクをしたいですこのように整列する:

enter image description here

graphviz dotにこのような形のグラフを作成することが可能ですか?

答えて

4

利用強い重みを持つ目に見えないエッジ:

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; 
} 

yields 

enter image description here

関連する問題