Tree Layout with Hidden Nodes

I have a diagram comprising a tree of iconic nodes, where different node types are added to distinct layers so that I can selectively toggle the visibility of certain node types. All of the links are in the document links layer. Hiding a node is achieved by setting Visible=false for it and its links, and then recursively for any destination nodes.

The problem is that the tree layout continues to process the hidden nodes, and therefore the resulting tree has too much “white space” in between the visible nodes.

How do I adjust the tree layout so that when nodes are not visible, they are not included in the calculations for horizontal and vertical spacing between the visible nodes?

I think the solution is to override GoLayoutTreeNetwork.AddNodesAndLinks to skip GoNodes or GoLinks that are not Visible. Override GoLayoutTree.CreateNetwork to create an instance of this custom network class.

This worked perfectly. Thank you.