5

I have a module that automatically outputs (in dot format) functions written in some kind of assembly language (the IR of my compiler). The nodes are the basic blocks printed using the 'record' shape. The problem is that the edges take a strange route, for example:

digraph {
node [shape = record];
n0[label="{<name> entry | <body> store i, 0\nstore sum, 0\ngoto test | {<target> target}}"];
n1[label="{<name> test | <body> t2 = load i\nif t4, body,   done | {<true> true | <false> false}}"]
n2[label="{<name> body | <body> t5 = load sum\ngoto test | {<target> target}}"];
n3[color=firebrick3, label="{<name> done | <body> t9 = load sum\nret t9}}"];
n0:target:s -> n1:name:n
n1:true:s -> n2:name:n
n1:false:s -> n3:name:n
n2:target:s -> n1:name:n
}

And an image:

What can I do so that the edge from 'target' to 'test' is placed on the left side?

2
  • Can you be specific about what criteria you want graphs to follow in general for routing arrows? E.g. you want to minimize crossings?
    – LarsH
    Commented Nov 6, 2010 at 10:09
  • I want that the edge from 'target' to 'test' to be routed on the left side. Now it's looking really weired and can't really understand why such a route is chosen in the first place. Commented Nov 6, 2010 at 17:35

1 Answer 1

11

The simplest non-guru way is force that wayward link to attach on the "west" sides.

n2:target:w -> n1:name:w

This might work okay for this case. A more general way, but takes more thinking and coding, but would allow the edge to attach to the :s and :n if you desire that, is add an invisible node of size zero (color=white, or there might be a visibility attribute) and get from n2 to n1 using two edges. Have the arrowhead on only one of them. The invisible node would have to sit to the left of n1 or n2. Alas, my graphvis-fu is not strong enough to create a working example; maybe someone else can create one.

alt text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.