Tree visualization algorithm

Is there any algorithm for visualizing the structure of the data tree? I tried google search but could not find. I am pretty sure that this is not an easy task. Or does anyone have any ideas?

+5
algorithm tree visualization
Dec 03 2018-11-12T00:
source share
4 answers

Assumption: you want each node displayed in such a way that it is centered over its child nodes.

To achieve this, calculate the width of each node, which I define as the amount of horizontal space needed to display this node subtree, so that it does not overlap with its left or right sibling subtrees.

It leads to:

width = 1 + sum(widths of children nodes) 

So, take the first step in depth through the tree to calculate each node width. To display, do a width traversal to draw a tree level by level.

This is a rough idea of ​​how to do this. You might want to adjust the width calculation depending on how you want to render the tree.

+7
Dec 03 '11 at 16:07
source share

Tree mapping is probably what you are looking for. Graphviz is good for rendering graphical structures that are not specialized for tree structures. I could not find it again, but I remember reading in a scientific article that treemaps (I think voronoi) are optimal for representing tree structures, relative to the place they consume, and the area can be used to represent some unit (for example, byte size for example).

Below are some alternatives.

Here is a good list of articles and other related information.

+3
Dec 03 2018-11-12T00:
source share

You can use the DOT language using the graphical interface.

+1
Dec 03 2018-11-12T00:
source share

You can also print the tree from left to right, that is, root in the very left, the first level is and so on. You will find a tree printed at each level, on its own column. The algorithm looks something like this:

 print(node, spaces): if node has left child: print(left_child, spaces + ' ') print spaces + node + '\n' if node has right child: print(right_child, spaces + ' ') 

This algorithm will print one node tree per line. Each level of the tree will recede to the right by some spaces. This algorithm will print the elements in ascending order, but the descending order can be achieved by processing the right child.

0
Jan 07 2018-12-12T00:
source share



All Articles