0

Looking for pseudo code to create a visual representation of a binary tree using 2D volume as data source.

Assumptions: Aware of root/parent structure. (Can have one root, but multiple large blocks, containing smaller blocks within. Can represent, HD folder structure, for example.)

Problem: Convert an associative array containing name and volume data to a visual 2D chart that automatically makes the decision to split volumes according to how much space is left for each subsequent area contained within the list.

Example of the resulting chart and associated data: The visual chart is the proverbial output of the pseudo code that would be required in order to solve this problem.

Ps: I couldn't find this elsewhere on StackOverflow. Has anyone done this before?

Output

The most elegant solution that I have found so far in a real-world application was WinDirStat:

enter image description here

Can anyone come up with pseudo code for something like this?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
InfiniteStack
  • 430
  • 2
  • 9
  • Can you clarify how a directory structure would be a binary tree? What are you looking for -- a general tree visualization or a binary tree visualization? – Stefan Haustein Jul 12 '17 at 18:45
  • Hi. Yes, I need data to be both: categorized and structured. Each largest box would be a category, separate from other boxes on that depth level. So this is why a tree was chosen. Data categorization would be done separately from visualization. What I am looking for is source code (or at least a clear pseudo code) for an algorithm that can visualize total volume as depicted in the screenshot. – InfiniteStack Jul 13 '17 at 13:25

1 Answers1

1

The kind of diagrams you are looking for are called "tree maps" and the most commonly used algorithms are called "slice and dice", "squarify" and "strip".

You can see these algorithms in action here and the a concrete implementation is "inspired by" Squarified Treemaps (Mark Bruls, Kees Huizing, and Jarke J. van Wijk) if you look at the sources.

Since binary trees are just a special form of trees, the generic versions of the algorithms should work in your case, too.

Sebastian
  • 7,729
  • 2
  • 37
  • 69