tree visualization
-
Any idea how to visualize a tree in C#? Like treeview but in graphical form, circles and links. Any libraries, controls maybe as I don't have much time? It seems correct visualization of any tree is not an easy thing :(
It's easy with the right approach: Position the leaves first. If each leaf has its own space in the Y dimension (i.e. no other nodes under it), you can easily assign Y coordinates for all the leaves. Just go through them from left to right, incrementing the Y coordinate according to each leaf's width and the gap between adjacent leaves. The X coordinates come from the leaves' depths. The next step is to assign coordinates to the interior nodes. One approach is to position each interior node in the middle above its leaves. Finally go through all the nodes, drawing them at their assigned coordinates, and drawing links from each interior node to its children.