2010-11-14 27 views
3

我想產生這樣的事情 - 節點的定位是最重要的事情,而不是邊緣的角度:排隊並行多個短的節點有一個高大的節點GraphViz的

+--------------+ 
|    | 
+--------------+ 
    |  | 
    V  V 
+-----+ +-----+ <--- alignment at top 
|  | |  | 
|  |->|  | 
|  | |  | 
+-----+ |  | 
    |  |  | 
    V  |  | 
+-----+ |  | 
|  | |  | 
|  |->|  | 
|  | |  | 
+-----+ +-----+ <--- alignment at bottom 
    |  | 
    V  V 
+--------------+ 
|    | 
+--------------+ 

的最好的我已經能夠提出的是將兩個左節點粘貼到具有白色(=>不可見)邊框的聚類子圖中,並將其中一個邊的權重設置爲0.但它仍然不太合適:

digraph G { 

    // scale things down for example 
    size="5,5" 
    rankdir=TD 
    ranksep=1 
    nodesep=1 

    node [shape=box] 

    node [width=5 height=2] 
    top 

    subgraph cluster_left 
    { 
     color=white 
     node [width=2 height=2] 
     left1 
     left2 
    } 

    node [width=2 height=5] 
    right 

    node [width=5 height=2] 
    bottom 

    top->left1 
    top->right 

    left1->left2 
    left1->right 
    left2->right [weight=0] 

    left2->bottom 
    right->bottom 
} 

這出來這樣的 - 不良排列:

關於如何獲得我想要的任何想法?

回答

3

我NEATO和這個腳本做到了:

digraph G { 
    layout="neato" 
    // scale things down for example 
    size="5,5" 
    rankdir=TD 
    ranksep=1 
    nodesep=1 

    node [shape=box] 

    top[pos="5,10!", width=5, height=2] 

    left1[pos="3.5,7!", width=2, height=2] 
    left2[pos="3.5,4!", width=2, height=2] 

    right[pos="6.5,5.5!", width=2, height=5] 

    bottom[pos="5,1!", width=5, height=2] 

    top->left1 
    top->right 

    left1->left2 
    left1->right 
    left2->right 

    left2->bottom 
    right->bottom 
} 

下面是結果:

alt text

+0

我給你的餅乾。我最終以類似的方式使用了neato,但我實際上編寫了一個python腳本來生成我傳遞給neato的文件,因爲我的位置座標需要以點爲單位(所以需要乘以72)。可惜的是,人們不能使用點本身來定位盒子,因爲在外部層次結構中將子圖視爲一個單獨的塊用於佈局。 – 2010-11-16 02:55:41