2010-11-14 31 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