Graphviz-随机节点顺序和通过标签的边 [英] Graphviz---random node order and edges going through labels

查看:74
本文介绍了Graphviz-随机节点顺序和通过标签的边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下点文件:

digraph finite_state_machine {
    {
        rank=same;
        node [shape = doublecircle]; q_5;
        node [shape = circle];
        q_1 -> q_2 [ label = "." ];
        q_1 -> q_2 [ label = "\epsilon" ];
        q_2 -> q_1 [ label = "\epsilon" ];
        q_2 -> q_3 [ label = "a" ];
        q_3 -> q_4 [ label = "^\wedge a" ];
        q_3 -> q_4 [ label = "\epsilon" ];
        q_4 -> q_3 [ label = "\epsilon" ];
        q_4 -> q_5 [ label = "b" ];
    }
}

给我的印象是节点将按照它们被提及的顺序出现.但是顺序对我来说似乎是随机的.我希望从左到右的顺序为下标的顺序.另外,边缘穿过标签,我该如何避免呢?

I was under the impression that the nodes would appear in the order they are mentioned. But the order seems random to me. I want the order, from left to right, to be in the order of the subscripts. Also, the edges go through the labels, how can I avoid that?

这是当前图像:

推荐答案

Graphviz确实根据彼此之间的边缘而不是按照出现的顺序对节点进行布局.如果希望边缘不影响任何节点的位置,可以通过添加constraint=false来实现.

Graphviz does lay out the nodes depending on the edge between each other, and not in order of appearance. If you want an edge not to influence the position of any node, you can do this by adding constraint=false.

因此,此图:

digraph finite_state_machine {
  pad=0.2;
    {
        rank=same;
        node [shape = doublecircle]; q_5;
        node [shape = circle];
        q_1 -> q_2 [ label = "." ];
        q_1 -> q_2 [ label = "\epsilon", constraint=false ];
        q_2 -> q_1 [ label = "\epsilon", constraint=false ];
        q_2 -> q_3 [ label = "a" ];
        q_3 -> q_4 [ label = "^\wedge a" ];
        q_3 -> q_4 [ label = "\epsilon", constraint=false ];
        q_4 -> q_3 [ label = "\epsilon", constraint=false ];
        q_4 -> q_5 [ label = "b" ];
    }
}

将帮助您

我必须添加pad以便不删除某些标签.

I had to add pad in order to not have some of the labels cut off.

这篇关于Graphviz-随机节点顺序和通过标签的边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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