如何从graphviz获得平衡图? [英] How to get balanced diagrams from graphviz?
本文介绍了如何从graphviz获得平衡图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
graphviz中是否有设置来生成像这样的平衡图:
Is there a setting in graphviz to generate balanced diagrams like this:
正确的图表http://img3.imageshack.us/img3/6423/testaah .png
当图表如下图所示更复杂时-它不像上面图那样平衡(4低于**).
When diagram is more complex like below - it isn't balanced like that above (4 is below **).
未正确平衡http://img51.imageshack.us/img51/6632/test2b.png
生成第二张图的代码:
graph
{
n1 [label="+"];
n1 -- n2;
n2 [label="/"];
n2 -- n3;
n3 [label="*"];
n3 -- n4;
n4 [label="1"];
n3 -- n5;
n5 [label="2"];
n2 -- n6;
n6 [label="3"];
n1 -- n7;
n7 [label="**"];
n7 -- n8;
n8 [label="4"];
n7 -- n9;
n9 [label="5"];
}
推荐答案
您可以引入新的不可见节点以重新平衡布局." (请参见 https://graphviz.org/faq/#FaqBalanceTree ).这样您的代码就变成了:
You can "introduce new, invisible nodes to re-balance the layout." (see https://graphviz.org/faq/#FaqBalanceTree). So your code becomes :
graph
{
n1 [label="+"];
n2 [label="/"];
n1 -- n2;
n1b1 [label="", width=.1, style=invis]
n1 -- n1b1 [style=invis]
n1b2 [label="", width=.1, style=invis]
n1 -- n1b2 [style=invis]
n1b3 [label="", width=.1, style=invis]
n1 -- n1b3 [style=invis]
n7 [label="**"];
n1 -- n7;
{ rank=same n2 -- n1b1 -- n1b2 -- n1b3 -- n7 [style=invis] }
n3 [label="*"];
n2 -- n3;
n2b1 [label="", width=.1, style=invis]
n2 -- n2b1 [style=invis]
n6 [label="3"];
n2 -- n6;
{ rank=same n3 -- n2b1 -- n6 [style=invis] }
n8 [label="4"];
n7 -- n8;
n7b1 [label="", width=.1, style=invis]
n7 -- n7b1 [style=invis]
n9 [label="5"];
n7 -- n9;
{ rank=same n8 -- n7b1 -- n9 [style=invis] }
n3 -- n4;
n4 [label="1"];
n3 -- n5;
n5 [label="2"];
}
使用此输出:
这篇关于如何从graphviz获得平衡图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文