2012-09-28 129 views
0

我想強制節點在圖中有一個指定的位置。這樣做時,不同的子圖不能正確對齊。生成該圖的代碼是:Graphviz子圖對齊問題

dot -Kfdp -n -Tpng -o sample.png test2.dot 

輸出圖爲: http://imageshack.us/photo/my-images/826/samplebg.png/ 與我得到的輸出的問題是:

digraph { 
rankdir=LR; 
labeljust="l"; 

subgraph cluster0{ 

label="t=0" 


n_3_0_0[label="192.168.8.6" 
    pos="15,12!"  
    ]; 
n_3_0_1[label="192.168.8.3" 
    pos="10,10!"  
    ]; 

n_3_0_0 -> n_3_0_1 ; 
n_3_0_1 -> n_3_0_0 ; 
}; 

subgraph cluster1{ 

label="t=5"  

n_3_1_0[label="192.168.8.6" 
    pos="15,12!"  
    ]; 
n_3_1_1[label="192.168.8.3" 
    pos="10,10!"  
    ]; 
n_3_1_2[label="192.168.8.9" 
    pos="10,12!"  
    ]; 

n_3_1_0 -> n_3_1_1 ; 
n_3_1_1 -> n_3_1_0 ; 
}; 


subgraph cluster2{ 

label="t=10" 

n_3_2_0[label="192.168.8.6" 
    pos="14,10!"  
    ]; 
n_3_2_1[label="192.168.8.3" 
    pos="10,10!"  
    ]; 
n_3_2_2[label="192.168.8.9" 
    pos="15,11!"  
    ]; 
n_3_2_3[label="192.168.8.8" 
    pos="18,12!"  
    ]; 

n_3_2_0 -> n_3_2_1 ; 

n_3_2_2 -> n_3_2_3 ; 
n_3_2_1 -> n_3_2_0 ; 
n_3_2_3 -> n_3_2_2 ; 
}; 

} 

我迫使節點位置編譯這段代碼 1.子圖不按t = 0,t-5,t = 10 ... 的順序顯示2.子圖不與左邊對齊。

我需要有輸出圖所示: http://imageshack.us/photo/my-images/253/needed.png/

Thnak你。

回答

0

由於您已經預先計算了所有節點的位置,因此您並不需要fdp - 您只需要遵守pos屬性的佈局。

所以你可能會產生這樣的輸出:

neato -Tpng sourcedot.gv -O 

但你不得不調整之前的節點位置,纔能有正確的堆疊,而不是超帶來的子圖:

digraph { 
rankdir=LR; 
labeljust="l"; 

subgraph cluster0{ 
label="t=0" 
n_3_0_0[label="192.168.8.6" 
    pos="15,4!" 
    ]; 
n_3_0_1[label="192.168.8.3" 
    pos="10,2!" 
    ]; 

n_3_0_0 -> n_3_0_1 ; 
n_3_0_1 -> n_3_0_0 ; 
}; 

subgraph cluster1{ 
label="t=5" 
n_3_1_0[label="192.168.8.6" 
    pos="15,7!" 
    ]; 
n_3_1_1[label="192.168.8.3" 
    pos="10,5!" 
    ]; 
n_3_1_2[label="192.168.8.9" 
    pos="10,7!" 
    ]; 

n_3_1_0 -> n_3_1_1 ; 
n_3_1_1 -> n_3_1_0 ; 
}; 


subgraph cluster2{ 
label="t=10" 
n_3_2_0[label="192.168.8.6" 
    pos="14,8!" 
    ]; 
n_3_2_1[label="192.168.8.3" 
    pos="10,8!" 
    ]; 
n_3_2_2[label="192.168.8.9" 
    pos="15,9!" 
    ]; 
n_3_2_3[label="192.168.8.8" 
    pos="18,10!" 
    ]; 

n_3_2_0 -> n_3_2_1 ; 

n_3_2_2 -> n_3_2_3 ; 
n_3_2_1 -> n_3_2_0 ; 
n_3_2_3 -> n_3_2_2 ; 
}; 

} 

enter image description here 得到的(一些小的調整仍然需要中間的子圖的標籤)

或者只是使用點,讓它對準的節點,太:

enter image description here

+0

我需要的第一個圖,您已經如上圖所示。但我無法生成它。我用naeto編譯,我可以得到這樣的東西: http://imageshack.us/f/833/sourcedotgv.png/ – OSMuser

+0

你正在使用什麼版本的graphviz?您可能需要更新 – marapet

+0

我的graphviz版本是2.26.3。 我試圖安裝graphviz版本2.29,它需要libgraphviz4(> = 2.18)。我無法在ubuntu12.04中安裝libgraphviz4,它與'libcdt4' – OSMuser