2

I have the following graphviz file. Right now, the edge labels are placed on a horizontal line, but I want the nodes to be placed on a horizontal line instead. How can I achieve this?

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

This is how it currently looks: current output

oskarkv
  • 2,329
  • 2
  • 21
  • 29

1 Answers1

4

You may use rank=same to force the same rank for all nodes:

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" ];
    }
}
marapet
  • 54,856
  • 12
  • 170
  • 184