Layer Spacing


I am currently using a LayeredDigraphLayout to do the following, but I have a problem with the spacing between the nodes. I would like the spacing to be different depending of the link, I don't want the LayerSpacing to be the same for all the links.
The first should have a spacing of 20, the second one 100 and the third one 75 for example.
<go:LayeredDigraphLayout ColumnSpacing="25" LayerSpacing="100" LayeringOption="OptimalLinkLength"/>
Thank you

Override LayeredDigraphLayout.NodeMinLayerSpace to control how much space a given node/vertex takes.

Here’s the default definition:

protected virtual double NodeMinLayerSpace(LayeredDigraphVertex v, bool topleft) { if (v.Node == null) return 0; Rect r = v.Bounds; Point p = v.Focus; if (this.Direction == 90 || this.Direction == 270) { if (topleft) return p.Y+10; else return r.Height-p.Y+10; } else { if (topleft) return p.X+10; else return r.Width-p.X+10; } }
If you set also set LayerSpacing to zero, you can completely control how much space is taken by each node, on each side of the node.

Thanks for your fast reply.

I got another question concerning NodeMinLayerSpace. I don't understand very well how the topleft boolean works and why each node has to loop two times in this method to get the spacing. Would it be ok if I put 0 to the second return and only specify the spacing on the first return as the following code shows ? or would it have some kind of impact in the diagram?
if (topleft)
return spacingwanted;
return 0;

That depends on where the Node.Location is in each of your nodes and whether they are different sizes. Try it and decide for yourself.