Avoid link overlap and keep manual route changes

Is there anyway to have links avoid nodes and not overlap other links? I don’t care if the links cross, I just don’t want them running along the same route so you can’t tell them apart. Also, if the user manually reshapes the link so that it does not overlap, is there some way to pin those route points that were changed so that if a connected node is moved the entire link does not reroute itself and go back to overlapping another link?

Are you using a layout such as LayeredDigraphLayout? That layout tries to avoid overlapping link segments unless they come from or go to the same port.

If not, and you are just talking about manually moving nodes, at this time there is no “avoids links” option that also avoids nodes.

But if you want a link to remember its route after manual reshaping of the route, you could set Route.Adjusting=“End” so that moving either node will not recompute those points. However, I believe that the Route.Routing=“AvoidsNodes” takes precedence over Route.Adjusting, so if you are using “AvoidsNodes”, that won’t help to remember manual reshapings of the link route. So you also need to stop “AvoidsNodes” routing if you want to get that behavior.

So, assuming your Link DataTemplate sets Link.Route.Routing=“AvoidsNodes”, you could try using the following customized LinkReshapingTool:

public class CustomLinkReshapingTool : LinkReshapingTool { protected override void DoReshape(Point newPoint) { base.DoReshape(newPoint); this.AdornedLink.Route.Routing = LinkRouting.Orthogonal; this.AdornedLink.Route.Adjusting = LinkAdjusting.End; } }
This means all links that are not manually reshaped will continue to exhibit “avoids nodes” routing. Once it has been reshaped it will no longer do so. The other consequence of remembering the intermediate points of the route is that if you move one node, and especially if you move both nodes, relatively far away, the link’s route will look pretty bad and will need to be reshaped again by the user.

I suppose you can think of situations where you would want to restore those two properties, as if it had not been manually reshaped. That policy is even more application-specific, so I’m not sure I can make any good suggestions.

You also will want to persist not only the reshaped route points, but the fact that it had been reshaped, so that you can set those two properties above differently from your template’s settings.