Dot Graph - edge connections overlap and don't space out


I'm trying too see whether i can use the Dot programming language to apply it to an old project of mine. The task is simple: create a high quality graph with ease. Unfortunately, while it has been fairly easy to implement the details of my graph, i wound up having to take loads of time just for adjusting the layout. Furthermore, it is quite unclear to me how the order of my instructions impact my graph, but it actually looks like putting the last instruction of my code at the beginning produces a completely different output!

Here is the code:

digraph {
TOP [shape=doublecircle]
TOP->TOP->{rank=same a->b->c->b->a}
a:s->c:s
a:nw->a:sw
c:ne->c:se
b:s->b:s
}

so. firstly, i finally mastered the 'get nodes to be on the same horizontal/vertical line' through ranking...

I also kinda fixed the problem of edges doing stupid interconnections (all free space below the graph for connections, and the edge winds up zig-zagging through the whole graph in an awkward way and overlapping everything?) using the direction indicators ":e" and the such (i believe they are called routes...), but it looks like graphviz isn't using them in a smart way, because the result looks funny to me.

Here is the output, how do i get it to avoid edge overlappings and make enough space for future (long) labels?

My graph

(made with dot -Tpng test.dot -o test.png)

(also, i would need to add a c->a edge at the bottom too, but adding one the "normal" way ruined everything..)

Thanks :)

Answers


You can use invisible nodes to "re-route" your edges as desired (edited as per comments below):

digraph
{
    /* layout */
    // node width to create space for longer labels
    node [ width = 1.75 ];
    { rank=same; a; b; c }

    /* nodes */
    t [ label = "TOP", shape = doublecircle, width = 1];
    a [ label = "short" ];
    b [ label = "medium" ];
    c [ label = "rather  l o n g"]
    // invisible nodes to 're-route' the edges
    x [ style = invis, shape = point, width = 0 ];
    y [ style = invis, shape = point, width = 0 ];

    /* edges */
    t -> t;
    t -> { a b c }
    t -> { a b c } [dir = back ];      // added for reverse arrows
    a -> b -> c -> b -> a;
    a:nw -> a:sw;
    c:ne -> c:se;
    b:s -> b:s;
    // put the invisible nodes at the desired places with invisible edges
    b -> x -> y [ style = invis ];
    // edges to invisible nodes must not have heads
    c:sw -> x [ arrowhead = "none" ];
    x -> a:se;
    a:s ->  y [ arrowhead = "none" ];
    y -> c:s;
}

yields


Need Your Help

Centering the titlebar in Android using an activity

android class android-activity centering titlebar

So I am trying to center my applications title using the first activity.java class that one starts out with.

how to replace names recursively via windows batch operation

windows scripting batch-file

I want to process a batch operation in a big directory. Actually I have the batch script for that process. But here , I have a problem. Some of the directory names, files names contain " " (space