2011-07-15 109 views
8

我編譯如下圖用:dot graph.dot -Tpdf -ograph.pdf,生產:擰緊點圖使它更對稱

enter image description here

結果是好的,但狀態轉換看起來很像一個spagetthi怪物,我有不知道我能做些什麼來解決這個問題。我嘗試了其他佈局:twopi, neato, etc.是否有參數允許它強制圖看起來更對稱一些?因爲整體畫面沒問題。

對我來說,似乎邊緣使用可用於構建邊緣描述的最小空間,也許這是問題所在?

我的圖表設計是否有缺陷?我應該在一個邊上寫入不同的狀態轉換,使用\ n分隔不同的轉換?

digraph finite_state_machine { 
    rankdir=LR; 
    edge [fontsize=26]; 
    node [shape = doublecircle, width=2.0, fontsize=24, fixedsize=true,style=filled, colorscheme=spectral5]; New [fillcolor=3] Terminated [fillcolor=5]; 
    node [shape = circle, width=2.0, fontsize=24, fixedsize=true, colorscheme=spectral5]; Runnable [fillcolor=4] Waiting [fillcolor=2] "Timed\nWaiting" [fillcolor=2] Blocked [fillcolor=1]; 
    New -> Runnable [ label = "Thread.start" ]; 
    Runnable -> Waiting [ label = "Object.wait" ]; 
    Runnable -> Waiting [ label = "Thread.sleep" ]; 
    Runnable -> Waiting [ label = "LockSupport.park" ]; 
    Waiting -> Blocked [ label = "Reacquire monitor lock after\nleaving Object.wait" ] 
    Waiting -> Blocked [label = "Spurious wake-up"] 
    "Timed\nWaiting" -> Blocked [ label = "Reaquire monitor lock after\n leaving Object.wait" ] 
    "Timed\nWaiting" -> Terminated [ label = "Exception" ] 
    "Timed\nWaiting" -> Blocked [ label = "Spurious wake-up" ] 
    Runnable -> "Timed\nWaiting" [ label = "Object.wait" ]; 
    Runnable -> Blocked [ label = "Contended Monitor\nEnter" ]; 
    Blocked -> Runnable [ label = "Contended Monitor\nEntered" ]; 
    Runnable -> Terminated [ label = "Thread finishes\nexecution" ] 
    Runnable -> Terminated [ label = "Exception" ] 
    Waiting -> Runnable [ label = "Object.notify\nObject.notifyAll" ] 
     Waiting -> Terminated [ label = "Exception" ] 
    "Timed\nWaiting" -> Runnable [ label = "Object.notify\nObject.notifyAll" ] 
} 

回答

6

我不認爲你的設計有缺陷,我認爲沒關係。點語法是可讀的,因此可以維護,結果是自動生成的圖形看起來通常是一樣的。

當然,你可以添加小的更正,使這個特定的圖更好(或至少不同)。例如,如果圖形的源由應用程序生成,其中一些可能難以實現。這裏有一些想法:


把佈局是更對稱,您可以嘗試對準等待通過設置終止以及定時等待阻止節點它們的group屬性的值相同(group=agroup=b)。

grouped nodes

它的工作罰款等待Teminated,但不是這麼好定時等待阻止 - 可能是因爲有這些節點之間的兩條邊。

您可以嘗試通過選取鏈接它們的邊緣之一併將它的weight屬性設置爲較高值來理清它們。

除此之外,我認爲圖形看起來更好了,因爲所有的邊緣更平滑,並有少無謂的曲線,尤其是 - 但不僅僅是 - 的Runnable之間等待


意大利麪效果是由於花鍵 - 也許它看起來不太麪條沒有花鍵?我試圖通過添加splines=compoundsplines=ortho(相同的結果):

group and compound

該圖使用稍少的垂直空間。這不是意大利麪條,但它是在我看來,不是更好?


你也可以嘗試splines=compound沒有組屬性,這應該使圖中的小更緊湊的(錯誤不一定漂亮)。或者乾脆利用邊緣的重量來矯正特別不愉快的邊緣。

在某些情況下,concentrate可以清除具有許多平行邊緣的圖形 - 在這種情況下,它並沒有真正的幫助。

+0

這是非常有益的,謝謝。我認爲這是你能得到的最好的。重量和組似乎是真正的交易! –