4 #include "typedefs.hpp" 5 #include "treeiterator_bones.hpp" 8 #ifndef H_PRUNER_TREE_BONES 9 #define H_PRUNER_TREE_BONES 1 12 #define MAX_TREE_SIZE 50000 35 template <
typename Data_Type =
bool>
39 bool is_dag_(
int i = -1,
int caller = -1,
bool up_search =
false);
40 void postorder_(uint i);
42 uint get_dist_tip2root_(uint start, uint count);
71 v_uint DIST_TIPS2ROOT;
79 Data_Type *
args =
nullptr;
88 std::function<void(Data_Type *, TreeIterator<Data_Type>&)>
fun;
94 fun(this->args, this->iter);
114 Tree(
const v_uint & parents_,
const v_uint & offspring_, uint & out);
119 const vv_uint * get_parents_ptr()
const {
return &this->
parents;};
120 const vv_uint * get_offspring_ptr()
const {
return &this->
offspring;};
121 const v_uint * get_postorder_ptr()
const {
return &this->
POSTORDER;};
124 vv_uint get_parents()
const {
return this->
parents;};
125 vv_uint get_offspring()
const {
return this->
offspring;};
126 v_uint get_postorder()
const {
return this->
POSTORDER;};
128 v_uint get_preorder()
const;
149 vv_uint get_edgelist()
const;
151 void print(
bool details =
true)
const;
155 bool is_connected()
const {
return this->POSTORDER.size() == this->N_NODES;};
158 void reset_visited() {
159 std::fill(this->visited.begin(), this->visited.end(),
false);
160 std::fill(this->visit_counts.begin(), this->visit_counts.end(), 0u);
164 uint set_postorder(
const v_uint & POSTORDER_,
bool check =
true);
void prune_postorder()
Do the tree-traversal using the postorder.
Definition: tree_meat.hpp:385
v_uint POSTORDER
Postorder sequence.
Definition: tree_bones.hpp:67
vv_uint offspring
Each nodes' offspring.
Definition: tree_bones.hpp:49
uint n_tips() const
Return the number of tips defined as nodes with no offspring.
Definition: tree_meat.hpp:467
int n_parents(uint i) const
Return the number of parents a given node has.
Definition: tree_meat.hpp:488
v_bool visited
List of already visited nodes (auxiliar)
Definition: tree_bones.hpp:53
std::function< void(Data_Type *, TreeIterator< Data_Type > &)> fun
Callable function during the the tree traversal.
Definition: tree_bones.hpp:88
void prune_preorder()
Do the tree-traversal using the preorder.
Definition: tree_meat.hpp:426
void eval_fun()
Evaluates the function by passing the arguments and the iterator.
Definition: tree_bones.hpp:91
uint n_edges() const
Returns the numner of edges.
Definition: tree_bones.hpp:139
v_uint get_tips() const
List of tips position indices.
Definition: tree_bones.hpp:131
Tree class.
Definition: tree_bones.hpp:36
v_uint visit_counts
Number of visits per node (auxilias)
Definition: tree_bones.hpp:55
vv_uint parents
Each nodes' parents.
Definition: tree_bones.hpp:47
int n_offspring(uint i) const
Return the number of offsprings a given node has.
Definition: tree_meat.hpp:479
uint n_nodes() const
Returns the numner of nodes.
Definition: tree_bones.hpp:137
Data_Type * args
Arbitrary set of arguments.
Definition: tree_bones.hpp:79
Definition: treeiterator_bones.hpp:12
v_uint get_dist_tip2root()
Distance of tips to the closest root.
Definition: tree_meat.hpp:344
v_uint TIPS
List of tip (leaves) indices.
Definition: tree_bones.hpp:70