Class marginal_tree

Class Documentation

class fwdpp::ts::marginal_tree

A non-recombining tree.

The tree is represented as a sparse tree data structure where several linked lists allow efficient retrieval of parent/child/siblings of nodes.

Version

0.7.0 Added to fwdpp

Version

0.7.1 Constructors throw exceptions when sample lists contain the same node ID more than once. Changed from struct to class in order to reuse some code in a private function. Initialization also tracks the total sample size, which is number of nonzero elements in sample_index_map.

Version

0.7.4 Update to include data structures for root tracking

Version

0.8.0 Now holds a list of samples. Samples may be assigned to groups.

Public Functions

template<typename SAMPLES>
marginal_tree(table_index_t nnodes, const SAMPLES &samples, bool advancing_sample_list)

samples may be either std::vector<table_index_t> or std::vector<fwdpp::ts::sample_group_map>. For the former, all sample nodes will be assigned group 0.

Parameters

template<typename SAMPLES>
marginal_tree(table_index_t nnodes, const SAMPLES &samples, const std::vector<table_index_t> preserved_nodes, bool advancing_sample_list)
marginal_tree(table_index_t nnodes)

Constructor

Todo:

Document

int num_roots() const

Return number of roots.

std::size_t sample_size() const

Number of samples.

std::vector<table_index_t>::const_iterator samples_list_begin() const

Beginning of samples list.

std::vector<table_index_t>::const_iterator samples_list_end() const

End itertor for samples list.

std::int32_t sample_group(table_index_t u) const

Return the sample group for node .

bool advancing_sample_list() const
std::size_t size() const

Return the length of the internal vectors.

table_index_t sample_table_index_to_node(table_index_t u) const

If u is a sample index, return the associated node id.

Public Members

std::vector<table_index_t> parents
std::vector<table_index_t> leaf_counts
std::vector<table_index_t> preserved_leaf_counts
std::vector<table_index_t> left_sib
std::vector<table_index_t> right_sib
std::vector<table_index_t> left_child
std::vector<table_index_t> right_child
std::vector<table_index_t> left_sample
std::vector<table_index_t> right_sample
std::vector<table_index_t> next_sample
std::vector<table_index_t> sample_index_map
std::vector<std::int8_t> above_sample
double left
double right
table_index_t left_root