【问题标题】:Node layering in GraphvizGraphviz 中的节点分层
【发布时间】:2010-12-18 07:46:46
【问题描述】:

我正在使用 Graphviz(用neato 编译)创建一个图表。该图包含许多重叠节点,非常好。但是,有一组大节点我更喜欢始终位于其他小节点之上——尽管我更喜欢首先在图中定义大节点(这使得它们被绘制在最底部)。

有什么办法可以强制这样做吗?

编辑:
这是一个小例子,只是为了澄清我的意思:

graph G {
    node [style=filled,fillcolor=black];
    BigNode [fillcolor=skyblue,shape=Msquare];

    node [style=filled,fillcolor=red,shape=circle];
    edge [style=invis]
    1 -- BigNode[len=0.5];
    2 -- BigNode[len=1];
}

我希望将 BigNode 绘制在节点 1 上。

【问题讨论】:

    标签: graph visualization graphviz dot neato


    【解决方案1】:

    我确实找到了一种(某种)解决方案...
    我发现如果你将节点定义推迟到最后,即使你之前为这个节点定义了边,它也会被绘制在最上面。
    我意识到这与我之前定义的相矛盾,但这是在这种情况下唯一可能的解决方案,也是我最终不得不使用的解决方案。

    在我的简短示例中,您可以这样做:

    graph G {
        node[style=filled,fillcolor=black];
        // Definition of BigNode moved to the end of the file
        /*BigNode [fillcolor=skyblue,shape=Msquare];*/ 
    
        node[style=filled,fillcolor=red,shape=circle];
        edge[style=invis]
        1 -- BigNode[len=0.5];
        2 -- BigNode[len=1];
    
        // Defined after already defining edges for BigNode
        BigNode [fillcolor=skyblue,shape=Msquare];
    }
    

    在结果图中,BigNode 被绘制在节点 1

    【讨论】:

      【解决方案2】:

      我认为这是不可能的。官方neato guide 在第 6 页到第 9 页讨论了节点分层。看起来您最多只能调整边的长度并固定节点:您实际上无法控制节点如何相互分层。

      【讨论】:

      • 对于上面的确切问题定义,不幸的是你是对的,没有解决方案。
      猜你喜欢
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 1970-01-01
      • 2019-08-29
      • 2014-10-09
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      相关资源
      最近更新 更多