2014-09-24 295 views
1

我試圖避免20-> 40和30-> 70之間的交叉線。有誰知道如何做到這一點?我使用單點來理順邊緣,但我會希望渲染引擎避免這些邊緣重疊。這裏是我的點代碼:Graphviz交叉邊緣

digraph { 
graph [splines="ortho", nodesep = "1", overlap = false]; 
node [shape=rectangle, color=lightgrey, style=filled ]; 

10 
20 
30 
40 
50 
60 
70 
80 
90 


node[shape=none, width=0, height=0 label=""]; 
edge[dir=none]; 

{rank=same; 
p1->10 
10->p2 
} 

p1->20 
p2->30 


{rank=same; 
p3->40 
40->p4 
} 

p3->50 
p4->60 


{rank=same; 
p5->70 
70->p6 
} 

p5->80 
p6->90 


20->40 
30->70 
} 

我想張貼圖片,但計算器不允許我這樣做...你可以明白我的意思,當你將代碼複製到:http://stamm-wilbrandt.de/GraphvizFiddle/

我非常感謝你的幫助!

+0

+1的鏈接GraphvizFiddle - 不知道這個工具,偉大的東西! – marapet 2014-09-24 18:39:43

回答

0

你可以通過添加DP5 P4之間一個看不見的邊緣給graphviz的一個暗示:

{ 
    rank=same; 
    p3 -> 40; 
    40 -> p4; 
    p4 -> p5 [style=invis]; // new invisible edge 
    p5 -> 70; 
    70 -> p6; 
} 

如果您無法添加可見邊(動態圖形生成),確保節點它們是子圖的一部分在子圖中首先出現,因此避免了前期節點定義。

在這個例子中,我刪除了腳本開始處的節點定義並且內聯了肘關節節點的樣式。

Here's the GraphvizFiddle

digraph { 
graph [splines="ortho", nodesep = "1", overlap = false]; 
node [shape=rectangle, color=lightgrey, style=filled ]; 

//node[shape=none, width=0, height=0, label=""]; 
edge[dir=none]; 

{ 
rank=same; 
p1[shape=none, width=0, height=0, label=""]; 
p2[shape=none, width=0, height=0, label=""]; 
p1->10 
10->p2 
} 

p1->20 
p2->30 

{ 
rank=same; 
p3[shape=none, width=0, height=0, label=""]; 
p4[shape=none, width=0, height=0, label=""]; 
p3->40 
40->p4 
} 


p3->50 
p4->60 

{ 
rank=same; 
p5[shape=none, width=0, height=0, label=""]; 
p6[shape=none, width=0, height=0, label=""]; 
p5->70 
70->p6 
} 

p5->80 
p6->90 


20->40 
30->70 

} 
+0

謝謝,這適用於這個靜態示例!我怎樣才能在動態模式下完成這項工作?我不知道在什麼「級別」節點將顯示如此動態添加隱藏的邊緣似乎很難......真的感謝你的幫助! – 2014-09-24 18:57:47

+0

我和你在一起,看到無形的邊緣!我添加了一個更通用的解決方案,希望它能適用於您的真實案例。 – marapet 2014-09-24 20:28:15

+0

靠近!因此,不提供節點定義使這項工作...不幸的是,我確實需要定義的節點,因爲節點的高度和寬度是根據標籤大小計算的... – 2014-09-24 21:00:03