Straight link routing with LayeredDigraphLayout

I am having issues with LayerDigraphLayout, I am not sure how to get the layout to show straight links its seems as if this would be possible but the ports and spacing seem to be constraining the link route. I have 3 types of nodes inputs(blue), outputs(red), functions(gray). Multiple inputs and outputs per functions, the function height will grow based on the maximum of the input count and output count. Below are some samples, along with my current diagram settings.

UniversalGraphLinksModel LinkFromPath=“Item1” LinkToPath=“Item2” NodeKeyPath=“Id” HasUndoManager=“False” UndoManager="{x:Null}"

Direction=“0” LayerSpacing=“15” LayeringOption=“OptimalLinkLength” ColumnSpacing=“7”
AggressiveOption=“More” InitializeOption=“DepthFirstOut” CycleRemoveOption=“Greedy” PackOption=“All” SetsPortSpots=“False”

Route Routing=“Normal” FromSpot=“RightSide” ToSpot=“LeftSide”

go:Part.Selectable=“True” go:Part.Movable=“True”
go:Node.Avoidable=“True” go:Node.AvoidableMargin=“1”


LayeredDigraphLayout tries to position each vertex by putting its center at a particular multiple of the ColumnSpacing property. If the ports are not spaced the same distance apart (on center), then the links cannot be straight. So with the way that you are positioning your ports, the routing cannot work.

Although to be fair, I’m not entirely confident that if you were to get all ports to be positioned at multiples of some column spacing property (independent of node sizes and positions), that LayeredDigraphLayout would always cause simple alignments of nodes with their connected ports.

Is there a setting for how far the ports should be spaced? I am not setting the ports manually, i have SetsPortSpots=false, so i am assuming there is some sort of algorithm within the layout that is determining that spacing. Any way to customize that spacing?

I also understand that in some cases they wont always be able to be straight, but i would like to solve some of the cases.

If you are using “…Side” Spots, then the connection points are evenly spaced along the side. So it depends on the number of links connecting on that side and how long the side is.

I suppose in the simple cases you could do some post-processing to shift the singly-connected nodes just a few units (at maximum) if it made them line up with their connection point at the other node. If you wanted to shift them more, you’d risk overlapping nodes, unless you take care to avoid that.

You could do that in an override of LayeredDigraphLayout.LayoutNodesAndLinks. Call the base method and then iterate over the .Network.Vertexes to see if the vertex has a single Vertex.EdgeCount and whether the Vertex.Center.Y value is close to the other end of the link’s Y value. If so, move the Vertex.Node accordingly.

Thank you, this will give me a good idea on where to start.