skbio.tree.BPTree.postorder_select#

BPTree.postorder_select(k)[source]#

Index of the node with a given postorder rank.

Parameters:
kint

Postorder rank to look up, from 1 to the number of nodes (the root).

Returns:
int

Index of the node whose postorder rank is k, or -1 if k is not a rank of this tree.

Notes

The inverse of postorder_rank. Returns an integer index into the parentheses bit array, not a node object. postorder yields the nodes in this order.

Examples

>>> from skbio.tree import BPTree
>>> tree = BPTree.read(["((a,b)c,(d,e)f)r;"])
>>> [tree.name(tree.postorder_select(k)) for k in range(1, len(tree) + 1)]
['a', 'b', 'c', 'd', 'e', 'f', 'r']
>>> tree.postorder_rank(tree.postorder_select(4))
4
>>> tree.postorder_select(len(tree) + 1)
-1