I am using the NLayeredGraphLayout to create a graph from a dataset. The diagram can have multiple top-level nodes (nodes with no parent). When dealing with multiple top-level nodes, I noticed that the algorithm places these shapes in various locations within the document. To remedy this, I created a "dummy" root node and parented all top-level nodes to this new dummy node. Now the graph draws all top-level nodes correctly. The problem is, I do not want the dummy node (and the edges from the dummy node to the top-level nodes) to display. I set the Visible = false property of the root node and edges. While these nodes are hidden as expected, there is now a blank white space above the top-level nodes.
How would I go about getting the top level nodes to draw as they do now, but without white space left by hiding the dummy node and its edges?
Any help would be greatly appreciated.
Thanks.
Hi,
there are 2 possible solutions:
Best Regards,Nevron Support Team
Thanks for the response. I set the NodeRank to TopMost and removed the root node. The diagram doesn't display correctly. Here is the layout code:
layout.NodeRank = LayeredLayoutNodeRank.TopMost;
layout.Direction = LayoutDirection.TopToBottom;
layout.LayerAlignment = RelativeAlignment.Near;
graphImporter.Layout = layout;
See the attachment for the rendered graph. All nodes without paths are nodes where the parentid is set to null. These are the nodes I would have thought were considered top-level nodes. The CDROP_P and LOCATE nodes seem to render correctly.