Random hierarchy

random_binary_partition_tree(num_leaves, …)

Random binary partition tree with a controlled amount of asymmetry/unbalancedness.

random_binary_partition_tree(num_leaves, asymmetry_probability)[source]

Random binary partition tree with a controlled amount of asymmetry/unbalancedness.

The tree is grown from the root to the leaves. At each step, the algorithm randomly select one of the growable leaf node of the current tree. Two children are added to the selected node; the number of leaf nodes is hence increased by one. Then,

  • with probability \(1-asymmetry\_probability\), both new children are marked as growable

  • with probability \(asymmetry\_probability\), only one of the children is marked as growable

The altitudes of the returned hierarchy are obtained with attribute_regular_altitudes(): The regular altitudes is comprised between 0 and 1 and is inversely proportional to the depth of a node.

A valid minimal connected graph (a tree) is associated to the leaves of the tree.

Parameters
  • num_leaves – expected number of leaves in the generated tree

  • asymmetry_probability – real value between 0 and 1. At 0 the tree is perfectly unbalanced, at 1 it is perfectly balanced (if num_leaves is a power of 2)

Returns

a tree (Concept CptBinaryHierarchy) and its node altitudes