Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphviz---how do I make edges not cross each other; choose self-loop edge position

Tags:

graphviz

I have the following dotfile:

digraph finite_state_machine {                                                                                                                                                                                  
    pad=0.2;
    {
        rank=same;
        node [shape = doublecircle]; q_3;
        node [shape = circle];
        q_1 [ label = <<b><i>q<sub>1</sub></i></b>> ];
        q_2 [ label = <<b><i>q<sub>2</sub></i></b>> ];
        q_3 [ label = <<b><i>q<sub>3</sub></i></b>> ];
        q_1 -> q_1 [ label = <<b><i>^a</i></b>> ];
        q_1 -> q_2 [ label = <<b><i>a</i></b>> ];
        q_2 -> q_2 [ label = <<b><i>^b</i></b>> ];
        q_2 -> q_3 [ label = <<b><i>b</i></b>> ];
    }
}

And I get the following output: output image

I want the self loops to be on top of the nodes, and not cross the other edges. And, if possible, more loopy loops. How can I achieve that?

I want it to look something like this:

like image 284
oskarkv Avatar asked Oct 15 '12 13:10

oskarkv


1 Answers

You may use ports/compass points:

q_1:e -> q_1:w [ label = <<b><i>^a</i></b>> ];
q_2:e -> q_2:w [ label = <<b><i>^b</i></b>> ];

graphviz with loopy loops

or using nw/ne as compass points:

Event loopier loops

like image 149
marapet Avatar answered Nov 11 '22 19:11

marapet