【问题标题】:Top-left to bottom-right tree in GraphvizGraphviz 中从左上到右下的树
【发布时间】:2021-11-05 08:27:26
【问题描述】:

假设我从这个开始:

graph {
    graph [splines=ortho]
    node [fontname="Sans-Serif" shape=record]
    rankdir=LR

    "Parent" -- "Child 1"
    "Parent" -- "Child 2"
    "Parent" -- "Child 3"
    "Parent" -- "Child 4 and then some"

}

这会产生:

我需要改变什么来获得它(对于后续级别等等)?

谢谢!

【问题讨论】:

    标签: graphviz dot


    【解决方案1】:

    出乎意料的困难。正交被 DIY 正交边缘取代,使用伪不可见节点。

    graph {
        // note: renaming the nodes was optional
        graph [splines=false ] // was ortho
        node  [fontname="Sans-Serif" shape=rect ]    // record features unused
        rankdir=LR  // ranks are now vertical!
        { // non-visible nodes (i1 i2 i3 i4) used to connect edges
          rank=same
          node [label="" peripheries=0]  // keep same size as other nodes, 
                                         // but do not draw (peripheries)
          edge [headclip=false tailclip=false]  // draw center-to-center
          i1:c -- i2:c -- i3:c -- i4:c
        }
        {node [group=T] P  C1}    //group used to place "child 1" w/ parent
        P [label="Parent"]
       {
          rank=same
          C1 [label="Child 1"]
          C2 [label="Child 2"]
          C3 [label="Child 3"]
          C4 [label="Child 4 and then some"]
        }    
        P -- i1  [headclip=false]
        edge     [tailclip=false]
        i1 -- C1
        i2 -- C2
        i3 -- C3
        i4 -- C4
    }
    

    捐赠:

    【讨论】:

    • 天啊!我自己不可能找到它。谢谢!
    猜你喜欢
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    • 2015-05-08
    • 2010-12-03
    • 1970-01-01
    • 2016-03-17
    相关资源
    最近更新 更多