cassiopeia.sim.CompleteBinarySimulator#

class cassiopeia.sim.CompleteBinarySimulator(num_cells=None, depth=None)[source]#

Simulate a complete binary tree.

Internally, this class uses nx.balanced_tree() to generate a perfectly balanced binary tree of specified size. Only one of num_cells or depth should be provided. All branches have equal length that is normalized by the height of the tree (i.e. the tree has height 1).

Parameters:
num_cells Optional[int] (default: None)

Number of cells to simulate. Needs to be a power of 2. The depth of the tree will be log2(num_cells).

depth Optional[int] (default: None)

Depth of the tree. The number of cells will be 2^depth.

Raises:

TreeSimulatorError if neither or both num_cells or depth are – provided, if num_cells is not a power of 2, or if the calculated depth is not greater than 0.

Methods

simulate_tree()[source]#

Simulates a complete binary tree.

Return type:

CassiopeiaTree

Returns:

A CassiopeiaTree with the tree topology initialized with the simulated tree