Getting information from tree nodes

I am working with a tree data structure and am trying to find a way to calculate the information I can get from the tree nodes.

I'm wondering if there are any existing methods that can assign a higher numerical value to a node that appears less frequently at a lower level (distance from the root of the tree) than the same nodes at a higher level and higher frequency.

To give an example, I want to give more value to the node Book, at level 2 appearing once, then at level 3 appearing three times.

Feel any suggestions / pointers to methods that achieve something like this.

Thanks,

Prateek

+2


a source to share


2 answers


One metric that I just thought of is this: for a label, k

let this value be the sum of the levels at which it appears. So if it appears in root and root left child, let the value be 1.

Then your most "important" labels are the ones with the lowest value.



EDIT: This will make the root more important than the label of its children, even if they are both the same. So some scaling in the number of occurrences might be ok.

+1


a source


It depends on what value you give it at each level.

Just multiply by a number that decreases as you move down the levels in the tree. For example, n_nodes * 1/(3^n)

where n is the tree level. So a node at level 2 gets a value of 1/4, and 3 nodes in level 3 get a value of 1/9. So a single node at level 2 is more significant.



Adjust the denominator to your liking. As long as it increases with n, it will give more importance to the nodes higher in the tree.

+1


a source







All Articles