Graphviz - 将节点放在水平线上

时间:2012-10-03 14:41:16

标签: graphviz

我有以下graphviz文件。现在,边缘标签放在水平线上,但我希望节点放在水平线上。我怎样才能做到这一点?

 digraph finite_state_machine {
    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" ];
}

目前的状态如下:current output

1 个答案:

答案 0 :(得分:3)

您可以使用rank=same强制所有节点使用相同的排名:

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" ];
    }
}