bartz.grove.format_tree

bartz.grove.format_tree(tree, *, print_all=False)[source]

Convert a tree to a human-readable string.

Parameters:
  • tree (TreeHeaps) – A single tree to format.

  • print_all (bool, default: False) – If True, also print the contents of unused node slots in the arrays. An element of leaf_tree is printed at the first node of its own that is not a decision node.

Returns:

str – A string representation of the tree.

Notes

Each line starts with the index of the node in the heap, followed by the index of its value in TreeHeaps.leaf_tree, see node_to_leaf_index.