graphviz树中的儿童顺序 [英] children order in graphviz tree

查看:103
本文介绍了graphviz树中的儿童顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下那棵树:

digraph G {
    subgraph cluster0{
        37[label="+"];
        42[label="a"];
        44[label="b"];
        47[label="*"];
        46[label="c"];
        49[label="d"];
        51[label="e"];
        53[label="f"];
        55[label="g"];
        57[label="h"];
        61[label="*"];
        60[label="i"];
        63[label="j"];
        37 -> 42[label="c"];
        37 -> 44[label="c"];
        37 -> 47[label="c"];
        37 -> 61[label="c"];
        42 -> 37[label="p"];
        44 -> 37[label="p"];
        47 -> 37[label="p"];
        47 -> 46[label="c"];
        47 -> 49[label="c"];
        47 -> 51[label="c"];
        47 -> 53[label="c"];
        47 -> 55[label="c"];
        47 -> 57[label="c"];
        46 -> 47[label="p"];
        49 -> 47[label="p"];
        51 -> 47[label="p"];
        53 -> 47[label="p"];
        55 -> 47[label="p"];
        57 -> 47[label="p"];
        61 -> 37[label="p"];
        61 -> 60[label="c"];
        61 -> 63[label="c"];
        60 -> 61[label="p"];
        63 -> 61[label="p"];
    }
}

输出在这里: http://i.imgur.com/q1qXkCT.png

第一个*子树中子级的顺序为:G H C D E F,但应为C D E F G H. 我已经注意到,如果删除subgraph cluster0{,则顺序是正确的,但是我不能这样做. 您还能提出其他解决方案吗?

Order of children in first * subtree is: G H C D E F, but it should be C D E F G H. I have noticed that if I delete subgraph cluster0{ the order is right, but I can't do it this way. Can you suggest any other solution?

推荐答案

在没有其他约束的情况下,Graphviz尝试保留节点的词法顺序.但是,边缘标签会占用空间并影响节点的位置,从而影响放置.

Graphviz attempts to retain the lexical ordering of nodes when there is no other constraint. However, the edge labels can affect placement as they take up space and can push nodes around.

如果您有必不可少的特定订单,请尝试

If you have a specific order that is essential, then try something like

{ rank = same; 
46 -> 49 -> 51 -> 53 -> 55 -> 57 [style = invis];
}

将附加的排序约束引入到图中.

to introduce the additional ordering constraint into the graph.

但是您需要注意这一点,因为它会以很难预测的方式使更复杂的图形失真.

You need to be careful with this though, as it can distort more complex graphs in ways that are very difficult to predict.

簇进一步隐瞒了使子图更紧凑的情况,并引入了非簇成员无法跨越的边界框,从而使大图中的问题进一步复杂化.

Clusters further complicate matters in larger graphs as they implicitly attempt to make the subgraph more compact and introduce a bounding box that non-cluster members cannot cross.

这篇关于graphviz树中的儿童顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆