treeflow.tree.topology.numpy_tree_topology module

class treeflow.tree.topology.numpy_tree_topology.NumpyTreeTopology(parent_indices: ndarray, taxon_set: TaxonSet | None = None)

Bases: NumpyTreeTopologyAttrs

Class representing a bifurcating tree topology as a composition of integer NumPy arrays.

For a phylogenetic tree with n taxa at the leaves, the representation maintains a labelling of the 1n-1 nodes with integer indices. The labelling convention is that the leaves are the first n indices and the root is at the last index (2n-2).

property taxon_count: int

Number of leaf taxa the tree is based on (n)

property node_count: int
property postorder_node_indices: ndarray
property child_indices: ndarray

Array of length 2n-2 representing the parent-child structure of a tree topology on n taxa.

The i th element of this array is the index of the parent of the i th indexed node in the tree, for every node except the root.

property preorder_indices: ndarray

Array of indices of length 2n-1 that form a pre-order traversal of the tree.

A pre-order traversal is an ordering of the nodes where every node is visited before its children, starting at the root.

property taxon_set: TaxonSet | None
parent_indices: ndarray