pruner  0.0-99
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
pruner::Tree< Data_Type > Class Template Reference

Tree class. More...

#include <pruner.hpp>

Public Member Functions

void eval_fun ()
 Evaluates the function by passing the arguments and the iterator.
 
 Tree (const v_uint &parents_, const v_uint &offspring_, uint &out)
 Creating method using parents and offpring. More...
 
const vv_uintget_parents_ptr () const
 
const vv_uintget_offspring_ptr () const
 
const v_uintget_postorder_ptr () const
 
vv_uint get_parents () const
 
vv_uint get_offspring () const
 
v_uint get_postorder () const
 
v_uint get_preorder () const
 
v_uint get_tips () const
 List of tips position indices.
 
v_uint get_dist_tip2root ()
 Distance of tips to the closest root.
 
uint n_nodes () const
 Returns the numner of nodes.
 
uint n_edges () const
 Returns the numner of edges.
 
uint n_tips () const
 Return the number of tips defined as nodes with no offspring.
 
int n_offspring (uint i) const
 Return the number of offsprings a given node has.
 
int n_parents (uint i) const
 Return the number of parents a given node has.
 
vv_uint get_edgelist () const
 
void print (bool details=true) const
 
bool is_dag ()
 
bool is_connected () const
 
void reset_visited ()
 
uint set_postorder (const v_uint &POSTORDER_, bool check=true)
 
void prune_postorder ()
 Do the tree-traversal using the postorder. More...
 
void prune_postorder (v_uint &seq)
 Do the tree-traversal using the postorder with a user specific sequence. More...
 
void prune_preorder ()
 Do the tree-traversal using the preorder. More...
 
void prune_preorder (v_uint &seq)
 Do the tree-traversal using the preorder with a user specific sequence. More...
 

Public Attributes

Data_Type * args = nullptr
 Arbitrary set of arguments.
 
std::function< void(Data_Type *, TreeIterator< Data_Type > &)> fun
 Callable function during the the tree traversal. More...
 

Protected Member Functions

bool is_dag_ (int i=-1, int caller=-1, bool up_search=false)
 
void postorder_ (uint i)
 
void postorder ()
 
uint get_dist_tip2root_ (uint start, uint count)
 

Protected Attributes

TreeIterator< Data_Type > iter
 
vv_uint parents
 Each nodes' parents.
 
vv_uint offspring
 Each nodes' offspring.
 
v_bool visited
 List of already visited nodes (auxiliar)
 
v_uint visit_counts
 Number of visits per node (auxilias)
 
uint N_NODES
 
uint N_EDGES
 
uint N_TIPS
 
v_uint POSTORDER
 Postorder sequence. More...
 
v_uint TIPS
 List of tip (leaves) indices.
 
v_uint DIST_TIPS2ROOT
 
friend Data_Type
 

Friends

class TreeIterator< Data_Type >
 

Detailed Description

template<typename Data_Type = bool>
class pruner::Tree< Data_Type >

Tree class.

Arguments to be passed to Tree::fun. The Tree class is the core of pruner. The most relevant members are

Examples:
00-hello-world.cpp, 01-adding-function.cpp, and 02-rcpp.cpp.

Constructor & Destructor Documentation

template<typename Data_Type >
Tree< Data_Type >::Tree ( const v_uint parents_,
const v_uint offspring_,
uint out 
)
inline

Creating method using parents and offpring.

The tree is initialized using an edgelist by listing each edges' parent and offspring. The ids of the nodes must range 0 through n - 1.

Parameters
parents_Ids of the parents
offspring_Ids of the offspring. Must be of the same length as parents_
outReturn codes. 0 means success.

Member Function Documentation

template<typename Data_Type >
void Tree< Data_Type >::prune_postorder ( )
inline

Do the tree-traversal using the postorder.

The user defined function fun will be called at each step. This allows users implementing their own model.

template<typename Data_Type >
void Tree< Data_Type >::prune_postorder ( v_uint seq)
inline

Do the tree-traversal using the postorder with a user specific sequence.

Same as prune_postorder but with a different sequence

Parameters
seqA new sequence to apply.
template<typename Data_Type >
void Tree< Data_Type >::prune_preorder ( )
inline

Do the tree-traversal using the preorder.

See Tree::prune_postorder.

template<typename Data_Type >
void Tree< Data_Type >::prune_preorder ( v_uint seq)
inline

Do the tree-traversal using the preorder with a user specific sequence.

Same as prune_preorder but with a different sequence

Parameters
seqA new sequence to apply.

Member Data Documentation

template<typename Data_Type = bool>
std::function<void(Data_Type *, TreeIterator<Data_Type>&)> pruner::Tree< Data_Type >::fun

Callable function during the the tree traversal.

The idea of this function is that the users can specify what to do during a call to Tree::prune_postorder and Tree::prune_preorder conditional on the current node. The argument of class TreeIterator allows them to get that information by accessing the member function TreeIterator::id.

template<typename Data_Type = bool>
v_uint pruner::Tree< Data_Type >::POSTORDER
protected

Postorder sequence.

The POSTORDER vector shows the order in which TreeIterator runs through the tree. This is set at the moment during which the tree is created.


The documentation for this class was generated from the following file: