Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a node in the center of the dot-generated graph

With the following dot code

digraph DG {
    G -> V;
    G -> E;
    G -> P;
    G -> C;
}

I generate the following graph

dot-generated graph

How could I move the node G in the centre? That is I wish to get something like this: wished result

p.s. My experiments with setting the rank of the edge didn't work out.

like image 526
Max Li Avatar asked Feb 07 '15 15:02

Max Li


1 Answers

For the general case, the easiest thing to do is to use twopi or neato instead of dot as your layout engine.

Twopi:

twopi layout

Neato:

neato

If you're truly confined to dot, this will give you close to what you want, though you'll have to customize each graph.

digraph g 
{
    P -> G [dir=back];
    subgraph clusterGVE {
        {rank=same V; G; E;}
        G -> V [constraint=false];
        G -> E;
        color=invis;
    };
    G -> C;
}

Dot

like image 75
Dan Avatar answered Nov 13 '22 13:11

Dan