treeflow.tree.topology.base_tree_topology module

class treeflow.tree.topology.base_tree_topology.BaseTreeTopology(parent_indices: TDataType)

Bases: Generic[TDataType]

parent_indices: TDataType
class treeflow.tree.topology.base_tree_topology.AbstractTreeTopology(parent_indices: TDataType)

Bases: BaseTreeTopology[TDataType], Generic[TDataType, TShapeType]

Class representing a bifurcating tree topology as a composition of integer 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).

abstract property child_indices: TDataType

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.

abstract property preorder_indices: TDataType

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.

abstract property taxon_count: TShapeType

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

property postorder_node_indices: TDataType
abstract property taxon_set: TaxonSet | None
parent_indices: TDataType