2011-07-06 52 views
3

基本問題是如何控制Graphviz圖中元素的垂直和水平定位。Graphviz中的佈局

考慮一下圖的摘錄(在wysiwig編輯器中創建)。

enter image description here

我試圖重現它的Graphviz弄清楚它是否適合我的目的。

digraph G { 
compound=true; 
node [shape=box]; 
edge [dir=none]; 
    subgraph cluster_tmk_web6 { 
     nginx [label="nginx-frontend TCP 0.0.0.0:80"]; 

     subgraph clusteradminapp { 
      unicorn [label="unicorn_rails TCP 127.0.0.1:8080"]; 
      subgraph clusterROR { 
      label="ROR v.2.1"; 
      brida [label="brida_face_client"]; 
      } 
      label="Admin App"; 
     } 

     memcached [label="memcached"]; 
     sphinx; 
     mongodb; 

     subgraph cluster_errbit { 
      unicorn2; 
      ror3; 
     } 

    label="tmk-web6.service.home"; 
    }  

nginx -> unicorn; 
memcached -> brida [lhead=clusterROR]; 


} 

而結果是這樣

enter image description here

我省略了一些箭頭,但定位是對我來說至關重要。如何將'memcached'和'sphinx'移動到集羣底部?如何將'mongodb'轉移到右側?最後,圖表將包含大小爲6到10個這樣的簇。我如何控制佈局,將一些集羣放在一排和其他地方 - 上方和下方?我想我應該在這裏使用「排名」屬性,但不知道如何。請幫忙。

回答

12

僅僅通過加入剩餘的邊緣(和兩個不可見邊)時,graphviz的輸出更接近你想要的結果:

digraph G { 
compound=true; 
node [shape=box]; 
edge [dir=none]; 
    subgraph cluster_tmk_web6 { 
     nginx [label="nginx-frontend TCP 0.0.0.0:80"]; 

     subgraph clusteradminapp { 
      unicorn [label="unicorn_rails TCP 127.0.0.1:8080"]; 
      subgraph clusterROR { 
      label="ROR v.2.1"; 
      brida [label="brida_face_client"]; 
      } 
      unicorn -> brida[style=invis]; 
      label="Admin App"; 
     } 

     memcached [label="memcached"]; 
     sphinx; 
     mongodb; 

     subgraph cluster_errbit { 
      unicorn2; 
      ror3; 
      unicorn2 -> ror3[style="invis"]; 
      label="Errbit"; 
     } 

    label="tmk-web6.service.home"; 
    }  

nginx -> unicorn; 
nginx -> unicorn2; 
brida -> memcached [lhead=clusterROR]; 
brida -> sphinx [lhead=clusterROR]; 
ror3 -> mongodb; 
} 

graphviz output

添加一些顏色等,和你差不多那裏。

但請記住,Graphviz不是一個wysiwyg工具 - 它的優點是自動節點佈局。

+0

同意。 GraphViz更多地用於生成佈局作爲輸出,而不是輸入。 – CodeFreezr

相關問題