2012-10-03 44 views
1

我有以下graphviz文件。現在,邊緣標籤放置在一條水平線上,但我希望節點放置在水平線上。我怎樣才能做到這一點?Graphviz - 將節點放置在水平線上

digraph finite_state_machine { 
    node [shape = doublecircle]; q_5; 
    node [shape = circle]; 
    q_1 -> q_2 [ label = "." ]; 
    q_1 -> q_2 [ label = "\epsilon" ]; 
    q_2 -> q_1 [ label = "\epsilon" ]; 
    q_2 -> q_3 [ label = "a" ]; 
    q_3 -> q_4 [ label = "^\wedge a" ]; 
    q_3 -> q_4 [ label = "\epsilon" ]; 
    q_4 -> q_3 [ label = "\epsilon" ]; 
    q_4 -> q_5 [ label = "b" ]; 
} 

這是它目前的樣子:current output

+0

請嘗試使用Rankdir = 「LR」 的節點。看看它是否有幫助。 –

回答

3

您可以使用rank=same強制同一級別的所有節點:

digraph finite_state_machine { 
{ 
rank=same; 
    node [shape = doublecircle]; q_5; 
    node [shape = circle]; 
    q_1 -> q_2 [ label = "." ]; 
    q_1 -> q_2 [ label = "\epsilon" ]; 
    q_2 -> q_1 [ label = "\epsilon" ]; 
    q_2 -> q_3 [ label = "a" ]; 
    q_3 -> q_4 [ label = "^\wedge a" ]; 
    q_3 -> q_4 [ label = "\epsilon" ]; 
    q_4 -> q_3 [ label = "\epsilon" ]; 
    q_4 -> q_5 [ label = "b" ]; 
    } 
} 
+0

謝謝!這有效,但我得到了新的問題......:p – oskarkv

+1

從煎鍋裏走進火爐......我回答了你的另一個問題。 – marapet