强制graphviz中节点的从左到右的顺序? [英] Force the left to right order of nodes in graphviz?

查看:304
本文介绍了强制graphviz中节点的从左到右的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想绘制的图如下所示:



I我使用了下面的点语言:

 图a {
A [shape = box; label =A]
B [shape = box; label =B]
al [shape = none; label =0]
bl [shape = none; label =1]
br [shape = none; label =0]

A - al [label =0];
A - B [label =1];
B - bl [label =0];
B - br [label =1];


然而,我的结果图如下所示:





如何强制graphviz生成的节点的左右顺序?此外,就决策树而言,这两棵树是否完全一样,即使从左到右的顺序不同?

要解决这个问题,您可以更改 B al 节点的顺序:

 图a {
A [shape = box; label =A]
al [shape = none; label =0]
B [shape = box; label =B]
bl [shape = none; label =1]
br [shape = none; label =0]

A - al [label =0];
A - B [label =1];
B - bl [label =0];
B - br [label =1];
}

顺便说一句,graphviz网站有一个关于这个问题的博客文章,你可以看看如果你得到一个机会。

I want to draw a decision tree chart using graphviz.

The graph I want to draw looks like this:

I am using the following dot language:

graph a {
  A [shape=box; label="A"]
  B [shape=box; label="B"]
  al [shape=none; label="0"]
  bl [shape=none; label="1"]
  br [shape=none; label="0"]

  A -- al [label="0"];
  A -- B [label="1"];
  B -- bl [label="0"];
  B -- br [label="1"];

}

However my resulting graph looks like this:

How can I force the left to right order of the nodes generated by graphviz? Furthermore, as far as decision trees go are these two trees exactly the same even though the left to right ordering is different?

解决方案

To fix this, you can just change the order of the B and al nodes:

graph a {
  A [shape=box; label="A"]
  al [shape=none; label="0"]
  B [shape=box; label="B"]
  bl [shape=none; label="1"]
  br [shape=none; label="0"]

  A -- al [label="0"];
  A -- B [label="1"];
  B -- bl [label="0"];
  B -- br [label="1"];
}

By the way, the graphviz website had a blog post about this problem which you can have a look at if you get a chance.

这篇关于强制graphviz中节点的从左到右的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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