Drawing a hierarchical tree: treemapping

I am trying to develop a hierarchical tree view in which the weight of each node is equal to the actual number of child nodes. The leaf unit has a weight of 1.

I want to arrange these elements so that they can be viewed, going deeper into the tree, showing the root categories (without parents) at the beginning. Clicking on a node causes the view to redraw itself to show only the descendants of that node.

The difficulty is that the size in pixels of a node must be proportional to its weight compared to neighboring nodes. According to Wikipedia, this is called a tree map, and I need a sheet algorithm that I tried to understand myself, but it seems more complex than I expected.

As an example, here's a Mac Os X program called GrandPerspective, which shows the folder sizes of your HD :

alt text
(source: arstechnica.com )

I want to arrange the nodes this way! (the size is of course proportional to the size of the folder)

Any suggestions?

thank

+3
source share
2 answers

The data structure used in the file system example that you are showing is most likely a KD tree . I'm not quite sure how well you solve the problem with the cards in the file system example, but that’s how I myself will go about solving the file system problem:

, . .

  • -
  • - , ( , ..).

, . , , . , , , . .

:

  • . .
  • . .

, , , ( knapsack?), , , .

EDIT: partition . , SO.

+2

treemap. , .

+2

Source: https://habr.com/ru/post/1733732/


All Articles