If there were at most 7-8 links per node, probably it wouldn't be that hard to arrange this, but there are some nodes with 15 or more links (e.g.the Stop.RiskWatch and Postprocess Cubes ones), and it's not possible to avoid crossings while also arranging nodes in layers and keeping connected nodes close to each other. Since the nodes have very narrow shapes, you will get better results if you run horizontal layered layout, this way the links will have more space for bending around the nodes. E.g. this leaves 6-7 links overlapping with nodes, and you could also move the links to back of Z order to prevent them from crossing over nodes:
foreach (var node in diagram.Nodes)
node.AnchorPattern = AnchorPattern.LeftInRightOut;
var ll = new LayeredLayout();
ll.Anchoring = Anchoring.Reassign;
ll.NodeDistance = 15;
ll.LayerDistance = 20;
ll.Orientation = MindFusion.Diagramming.Layout.Orientation.Horizontal;
ll.Direction = Direction.Straight;
ll.IgnoreNodeSize = true;
ll.EnforceLinkFlow = true;
ll.Arrange(diagram);
If you prefer a vertical layout, try this code, which makes it as compact as possible, and does some post-processing to avoid nodes overlapping:
foreach (var node in diagram.Nodes)
node.AnchorPattern = AnchorPattern.TopInBottomOut;
var ll = new LayeredLayout();
ll.Anchoring = Anchoring.Reassign;
ll.NodeDistance = 30;
ll.LayerDistance = 30;
ll.Direction = Direction.Straight;
ll.IgnoreNodeSize = true;
ll.EnforceLinkFlow = true;
ll.Arrange(diagram);
var layers = new Dictionary<int, List<DiagramNode>>();
foreach (var node in diagram.Nodes)
{
if (!ll.Statistics.NodeLayerIndices.ContainsKey(node))
continue;
var l = ll.Statistics.NodeLayerIndices[node];
if (!layers.ContainsKey(l))
layers[l] = new List<DiagramNode>();
layers[l].Add(node);
}
foreach (var layer in layers.Values)
{
layer.Sort((n1, n2) => n1.Bounds.X.CompareTo(n2.Bounds.X));
for (int i = 1; i < layer.Count; i++)
{
var node = layer[i];
var prev = layer[i - 1];
if (node.Bounds.Left <= prev.Bounds.Right)
node.Move(prev.Bounds.Right + 5, node.Bounds.Y);
}
}
Some other layout classes you might try that seem to create legible layouts for this graph are CascadeLayout, TopologicalLayout and AnnealLayout, but they don't arrange nodes in layers.
I hope that helps,
Stoyan