Node spacing with LayeredDigraph

I’m using GoLayoutLayeredDigraph to automatically lay out nodes. The problem I have is that the resulting nodes in a given line (moving horizontally) are spaced very far apart. I’ve tried setting the ColumnSpacing on the digraph object to 0.0F and the nodes are still spaced very far appart.

I want to squeeze more information (nodes/links) into a given space but I’m currently getting too much whitespace between the nodes.

Are there any settings on the GoLayoutLayeredDigraph object I should tweak? Are there any other techniques you can recommend?


I don’t think you can set ColumnSpacing to zero (or negative) – try setting it to 1 instead.

I don’t see a difference between 0 and 1.
Here is what is produced with either setting:

What I’d like to do is have the two outer nodes “mon-pod2” and “t40-10” sit much closer to the center node “t40-15”. There appears to be no graphical reason (i.e. overlapped text or links or link paths) why they should be so far apart. Ideally, the bottom row of nodes would sit right next to each other with only the smallest amount of whitespace between them. Any ideas?

If you try LayoutDemo, or the BeatPaths sample, you’ll see that nodes can be placed a lot closer to each other than in your results.

How large are those nodes, really? Can you look at a node’s Bounds programmatically?

It’s also possible to artificially enlarge the size of a GoLayoutLayeredDigraphNode (corresponding to a real GoNode), but I assume you haven’t done that…

Here are the Bounds properties for each of the four nodes before calling PerformLayout … that’s why the X & Y are funky, but the Height/Width are correct.


I’m going to step through and see how the H and W may vary over time. Is there a way to “trim” the bounds of a node if its too large? Is there any kind of “ComputeBounds” business with nodes that I would have to do?

Well, those node widths seem to be much bigger than their appearances would warrant.

How are your nodes implemented? It looks like a plain GoIconicNode would work just fine.

The nodes inherit from GoIconicNode. In the ctor I call base.Initialize with a ResourceManager that loads the images used by the node. It’s right after the call to Initialize that the width jumps up so high. The image used is linked into the main assebly.

I’m wondering if the large width has something to do with how the ResourceManager … um, manages the resources. That is, if its doing some kind of scaling or … I dont know what.

The label at the bottom is implemented as a GoPort with it’s PortObject set to an instance of a GoText object.

And other than a few custom properties that it hold on to, it pretty much IS a GoIconicNode.

I just looked at the object returned by ResourceManager.GetObject(“BlueRect”) and it is a Bitmap with Height:40, Width: 52, so I’m confused why the node’s Bounds are jumping by so much after the call to Initialize.

The width is much further off than the height, so I’m wondering if it’s the label or the port that is throwing things off.

Make the Bitmap “selectable=true” so you can see what GoDiagram thinks its bounds is when you select it.