2012-03-26 31 views
4

欲生成的Graphviz下面的圖時:填充使用的Graphviz和NEATO

Desired layout

爲原因解釋here,這樣:

digraph 
{ 
    layout=dot; 
    rankdir="LR"; 
    overlap = true; 
    node[shape=record, height="0.4", width="0.4"]; 
    edge[dir=none]; 

    A; B; C; D; E; F; G; H; I; 

    A -> B -> C; 
    D -> E -> F; 
    G -> H -> I; 
    edge[constraint=false]; 
    A -> D -> G; 

    subgraph clusterX 
    { 
     label="Cluster 1"; 
     A; B; 
    } 

    subgraph clusterY 
    { 
     label="Cluster 2"; 
     E; F; H; I; 
    } 

} 

產生這樣的:

Not desired layout

some careful tweaking of the order of appearance of nodes

F; E; I; H; D; G; A; B; C; 

我得到正確的結果。

雖然這個作品,我想在節點的位置更直接的控制,所以我試圖切換到NEATO,這樣我可以使用POS強制節點位置:

graph g 
{ 
    layout=neato; 
    node[shape=record, height="0.4", width="0.4"]; 
    edge[dir=none]; 

    A [pos="1,3!"]; 
    B [pos="2,3!"]; 
    C [pos="3,3!"]; 
    D [pos="1,2!"]; 
    E [pos="2,2!"]; 
    F [pos="3,2!"]; 
    G [pos="1,1!"]; 
    H [pos="2,1!"]; 
    I [pos="3,1!"]; 

    A -- B -- C; 
    D -- E -- F; 
    G -- H -- I; 
    A -- D -- G; 

    subgraph clusterX 
    { 
     label="Cluster 1"; 
     A; 
     B; 
    } 

    subgraph clusterY 
    { 
     label="Cluster 2"; 
     E; F; H; I; 
    } 
} 

此給出以下結果:

enter image description here

我怎樣才能得到NEATO到集羣中添加集羣邊界和節點之間的填充(在斑點做同樣的方式)?

回答

4

我討厭參加聚會,但我不認爲neato-fixed-position-and-clusters方法會成功。

集羣支持依賴於佈局引擎 - not all engines support it to the same degree

需要注意的是,好的和壞的,羣子圖不是DOT 語言的一部分,而是完全由一定的 堅持一個語法約定佈局引擎。

Neato does not seem to be a part of the engines supporting clusters,雖然fdp不支持NEATO喜歡的佈局,它not support fixed positions

在上述鏈接的論壇條目中,ERG建議在某些時候使用gvpr腳本來實現此目的 - 可能不是您想到的解決方案。

順便說一下,圖不應該是有向圖,我會收到警告,並用--代替所有->

+0

Thanks @marapet。看起來我不得不在這裏改變我的方法。我很欣賞你提供的信息和鏈接。我已經更新了該問題以刪除有向邊。 – 2012-03-28 17:30:28