【问题标题】:Lining up multiple short nodes in parallel with a single tall node in GraphViz在 GraphViz 中将多个短节点与单个高节点并行排列
【发布时间】:2010-11-15 06:50:20
【问题描述】:

我想生成这样的东西 - 节点的对齐是重要的,而不是边缘的角度:

+--------------+
|              |
+--------------+
   |        |
   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
}

结果是这样的 - 对齐不佳:

关于如何获得我想要的任何想法?

【问题讨论】:

    标签: alignment graphviz dot


    【解决方案1】:

    我用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
    }
    

    结果如下:

    【讨论】:

    • 我给你饼干。我最终以类似的方式使用了neato,但实际上我编写了一个python脚本来生成我传递给neato的文件,因为由于某种原因我的位置坐标需要以点为单位(因此需要乘以72)。遗憾的是,不能使用 dot 本身来定位框,方法是将子图视为单个块,以便在外部层次结构中进行布局。
    猜你喜欢
    • 2016-02-06
    • 1970-01-01
    • 2014-10-09
    • 2011-11-29
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多