2016-12-20 122 views
2

我正在處理自動生成的Graphviz(所以它需要是一個通用的解決方案,而不是針對此特定示例)。它繪製了網絡的拓撲結構。但集羣內部的結果看起來並不整齊。Graphviz:羣集中的排序節點

下面是拓撲:

enter image description here

這裏是associed代碼:

digraph G { 

splines=polyline; 

subgraph cluster_sh5sl8 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh5sl8_L1 [label = "L1"]; 
    label = "5/8"; 
} 
subgraph cluster_sh5sl10 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh5sl10_L1 [label = "L1"]; 
    label = "5/10"; 
} 
subgraph cluster_sh5sl12 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh5sl12_L1 [label = "L1"]; 
    label = "5/12"; 
} 
subgraph cluster_sh5sl14 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh5sl14_L1 [label = "L1"]; 
    label = "5/14"; 
} 
subgraph cluster_sh5sl16 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh5sl16_L1 [label = "L1"]; 
    label = "5/16"; 
} 
subgraph cluster_sh6sl3 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl3_L1 [label = "L1"]; 
    label = "6/3"; 
} 
subgraph cluster_sh6sl8 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl8_L1 [label = "L1"]; 
    label = "6/8"; 
} 
subgraph cluster_sh6sl10 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl10_L1 [label = "L1"]; 
    label = "6/10"; 
} 
subgraph cluster_sh6sl12 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl12_L1 [label = "L1"]; 
    label = "6/12"; 
} 
subgraph cluster_sh6sl14 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl14_L1 [label = "L1"]; 
    label = "6/14"; 
} 
subgraph cluster_sh6sl16 { 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh6sl16_L1 [label = "L1"]; 
    label = "6/16"; 
} 
subgraph cluster_sh30sl1 { 
    rank=same; 
    style=filled; 
    color=lightgrey; 
    node [style=filled,color=white]; 
    sh30sl1_9600 [label = "9600"]; sh30sl1_9590 [label = "9590"]; sh30sl1_9580 [label = "9580"]; sh30sl1_9570 [label = "9570"]; sh30sl1_9560 [label = "9560"]; sh30sl1_9280 [label = "9280"]; sh30sl1_9270 [label = "9270"]; sh30sl1_9260 [label = "9260"]; sh30sl1_9250 [label = "9250"]; sh30sl1_9220 [label = "9220"]; sh30sl1_9190 [label = "9190"]; sh30sl1_OMD [label = "OMD"]; 
    label = "30/1"; 
} 

sh30sl1_9570 -> sh5sl8_L1; 
sh30sl1_9560 -> sh5sl10_L1; 
sh30sl1_9280 -> sh5sl12_L1; 
sh30sl1_9270 -> sh5sl14_L1; 
sh30sl1_9260 -> sh5sl16_L1; 
sh30sl1_9220 -> sh6sl3_L1; 
sh30sl1_9250 -> sh6sl8_L1; 
sh30sl1_9190 -> sh6sl10_L1; 
sh30sl1_9600 -> sh6sl12_L1; 
sh30sl1_9590 -> sh6sl14_L1; 
sh30sl1_9580 -> sh6sl16_L1; 
sh6sl12_L1 -> sh30sl1_9600; 
sh6sl14_L1 -> sh30sl1_9590; 
sh6sl16_L1 -> sh30sl1_9580; 
sh5sl8_L1 -> sh30sl1_9570; 
sh5sl10_L1 -> sh30sl1_9560; 
sh5sl12_L1 -> sh30sl1_9280; 
sh5sl14_L1 -> sh30sl1_9270; 
sh5sl16_L1 -> sh30sl1_9260; 
sh6sl8_L1 -> sh30sl1_9250; 
sh6sl3_L1 -> sh30sl1_9220; 
} 

請注意,我使用FDP,但如果它的工作原理我可以用別的。目前,FDP給我最好的結果。

我該如何訂購?

我已經試過clusterrank, ranksep, nodesep, constraint=false,或者以其他順序調用它們等等。我嘗試創建一個univ inivible節點,並將羣集中的每個其他節點連接起來,使它們等距,但它不起作用。

回答

1

我沒有答案尚未將與生成的結果 - 我有一個類似的問題在哪裏工作我可以修改文件graphviz的自己:

<graphviz> 
    digraph hierachy { 
    rankdir="LR" 
    graph [ordering="out"]; 
    subgraph cluster_Hierachie { 
     label="Hierachie" 
     n0 
     n10000 
     n20000 
     n30000 
     n40000 
     n50000 
     n0->n10000 
     n0->n20000 
     n0->n30000 
     n0->n40000 
     n0->n50000 
    } 
    } 
</graphviz> 

其呈現爲: enter image description here

和迄今爲止發現的以下鏈接:

請注意,如何指定不同的建議 「排序=出」

digraph g { 
    ordering=out ; 

digraph bt { 
    graph [ordering="out"]; 

沒有這些工作對我來說,雖然https://stackoverflow.com/a/9169194/1497139了1名給予好評和https://stackoverflow.com/a/9168680/1497139有2個upvotes

http://www.graphviz.org/content/ordering-edges 建議使用

rank=same 

所以我嘗試:

<graphviz> 
    digraph hierachy { 
    rankdir="LR" 
    graph [ordering="out"]; 

    subgraph cluster_Hierachie { 
     label="Hierachie" 
     n0 
     n10000 
     n20000 
     n30000 
     n40000 
     n50000 
     n0->n10000 
     n0->n20000 
     n0->n30000 
     n0->n40000 
     n0->n50000 
     { 
     rank=same;n0;n10000;n20000;n30000;n40000;n50000 
     } 
    } 

    } 
</graphviz> 

其呈現爲: enter image description here

http://www.graphviz.org/content/cluster-changes-nodes-order

建議添加

style=invis 
{ rank=same 0 -- 1 [style=invis] 
} 

節點。我試過無濟於事,最終做

<graphviz> 
    digraph hierachy { 
    rankdir="LR" 
    graph [ordering="out"]; 

    subgraph cluster_Hierachie { 
     label="Hierachie" 
     n0 
     n10000 
     n20000 
     n30000 
     n40000 
     n50000 
     n0->n50000 
     n0->n40000 
     n0->n30000 
     n0->n20000 
     n0->n10000 
    } 
    } 
</graphviz> 

其呈現爲: enter image description here

,我考慮給定的反向排序的集羣奇怪的行爲是有效的變通。

+0

非常感謝您的詳細解答。我的問題更多地是關於子圖簇到子圖簇。 所以我改變了圖表,讓節點代表一個集羣,然後編輯svg文件使節點動態。通過點擊它,顯示子圖。 但是,非常感謝您的關注! – Sail