Location of the Strange edge in Graphviz Dot

I have a module that automatically outputs (in dotted format) functions written in some assembly language (IR of my compiler). Nodes are the basic blocks printed using the "record" form. The problem is that the edges choose a weird 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 picture:

What can I do so that the edge from the β€œtarget” to the β€œtest” is located on the left?

+5
source share
1 answer

The simplest way, not related to the guru, is a force that has feedback for attachment on the "western" sides.

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

This might work in this case. A more general way, but requires more thinking and coding, but allows you to snap the edge: s and: n, if you want to, adds an invisible node of zero size (color = white, or there may be an attribute of visibility) and get from n2 to n1 using two ribs. Take the arrowhead on only one of them. An invisible node would have to sit to the left of n1 or n2. Alas, my decanter fu is not strong enough to create a working example; maybe someone else can create it.

alt text

+9
source

All Articles