Prevent coincident edges in Microsoft Automatic Graph Layout (Rectilinear)

142 Views Asked by At

I am using the rectilinear edge router of the Microsoft Automatic Graph Layout library to perform routing of edges between nodes.

One of the problems I am having with it is that it does not seem to try at all to avoid coincident edges. (See "Coincident Lines" at Wolfram)

In other words, it allows the following:

+--------+     +--------+ 
| Node A |     | Node B |
+--------+     +--------+
     |             |
     |             |
     +-------------+
     | +----------------------------+ 
     | |       Obstacle Node        |
     | +----------------------------+
     +-------------+
     |             |
     |             |
+--------+     +--------+ 
| Node X |     | Node Y |
+--------+     +--------+

Whereas what I want is the following:

+--------+     +--------+ 
| Node A |     | Node B |
+--------+     +--------+
     |             |
   +-+             |
   | +-------------+
   | | +----------------------------+ 
   | | |       Obstacle Node        |
   | | +----------------------------+
   | +-------------+
   +-+             |
     |             |
+--------+     +--------+ 
| Node X |     | Node Y |
+--------+     +--------+

I do not mind when edges cross in some places, because you can still tell which edge goes where, but I do mind when they coincide, because when this happens, it is impossible to tell which edge goes where.

Is there any way to tell the MSAGL rectilinear edge router to avoid coincident edges?

1

There are 1 best solutions below

0
On

I was able to find a partial solution to my problem; A complete solution would be appreciated.

Edges to be routed are specified via the RectilinearEdgeRouter.AddEdgeGeometryToRoute() method. This method accepts an instance of EdgeGeometry as a parameter.

When creating an instance of EdgeGeometry, the LineWidth property specifies the width of the line that defines the edge. MSAGL takes this width into account when routing, so as to avoid, if possible, coincident lines.

However, when MSAGL has to choose between placing lines at a distance smaller than LineWidth versus adding more bends to avoid that, it seems to always favor coincident lines rather than adding more bends.

Fiddling with the BendPenaltyAsAPercentageOfDistance property of RectilinearEdgeRouter did not seem to have any effect.

A complete solution to my problem would somehow instruct the MSAGL rectilinear router to avoid an edge coinciding with another edge the same way that it avoids edges through obstacles, and to always create more bends in order to achieve this.