A toolkit for working with phylogenetic data.
v0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TreeNode Class Reference

#include <genesis/tree/tree/node.hpp>

Detailed Description

Definition at line 56 of file node.hpp.

Public Member Functions

 TreeNode ()
 
 TreeNode (size_t index, TreeLink *primary_link)
 
 TreeNode (TreeNode const &)=delete
 
 TreeNode (TreeNode &&)=delete
 
 ~TreeNode ()=default
 
template<class NodeDataType >
NodeDataType & data ()
 
template<class NodeDataType >
NodeDataType const & data () const
 
template<class NodeDataType >
NodeDataType * data_cast ()
 
template<class NodeDataType >
NodeDataType const * data_cast () const
 
BaseNodeDatadata_ptr ()
 Return a pointer to the data. More...
 
BaseNodeData const * data_ptr () const
 Return a const pointer to the data. More...
 
std::string dump () const
 Returns a one-line dump summary of the data of this node. More...
 
bool has_data () const
 Return true if the TreeNode has a data object assigned to it. More...
 
size_t index () const
 Return the index of this Node. More...
 
bool is_inner () const
 True iff the node is an inner node. More...
 
bool is_leaf () const
 True iff the node is a leaf/tip. More...
 
bool is_root () const
 True iff the node is the root of its Tree. More...
 
TreeLinklink ()
 Return the TreeLink that points towards the root. More...
 
TreeLink const & link () const
 Return the TreeLink that points towards the root. More...
 
TreeNodeoperator= (TreeNode const &)=delete
 
TreeNodeoperator= (TreeNode &&)=delete
 
TreeLinkprimary_link ()
 Return the TreeLink that points towards the root. More...
 
TreeLink const & primary_link () const
 Return the TreeLink that points towards the root. More...
 
size_t rank () const
 Rank of the node, i.e. how many immediate children it has. More...
 
TreeNodereset_data (std::unique_ptr< BaseNodeData > data)
 Reset the data pointer of this TreeNode. More...
 
TreeNodereset_index (size_t val)
 Reset the internal index of this TreeNode. More...
 
TreeNodereset_primary_link (TreeLink *val)
 Reset the internal pointer to the TreeLink of this TreeNode. More...
 

Friends

class Tree
 

Constructor & Destructor Documentation

TreeNode ( )
inline

Definition at line 70 of file node.hpp.

TreeNode ( size_t  index,
TreeLink primary_link 
)
inline

Definition at line 76 of file node.hpp.

~TreeNode ( )
default
TreeNode ( TreeNode const &  )
delete
TreeNode ( TreeNode &&  )
delete

Member Function Documentation

NodeDataType& data ( )
inline

Definition at line 108 of file node.hpp.

NodeDataType const& data ( ) const
inline

Definition at line 114 of file node.hpp.

NodeDataType* data_cast ( )
inline

Definition at line 120 of file node.hpp.

NodeDataType const* data_cast ( ) const
inline

Definition at line 126 of file node.hpp.

BaseNodeData * data_ptr ( )

Return a pointer to the data.

In most cases, using data<>() is more convenient. However, in some cases, this function might be necessary.

Definition at line 105 of file node.cpp.

BaseNodeData const * data_ptr ( ) const

Return a const pointer to the data.

In most cases, using data<>() is more convenient. However, in some cases, this function might be necessary.

Definition at line 116 of file node.cpp.

std::string dump ( ) const

Returns a one-line dump summary of the data of this node.

TODO this method assumes that the tree node has a name. not good.

Definition at line 223 of file node.cpp.

bool has_data ( ) const

Return true if the TreeNode has a data object assigned to it.

Definition at line 94 of file node.cpp.

size_t index ( ) const

Return the index of this Node.

Definition at line 48 of file node.cpp.

bool is_inner ( ) const

True iff the node is an inner node.

Definition at line 201 of file node.cpp.

bool is_leaf ( ) const

True iff the node is a leaf/tip.

Definition at line 193 of file node.cpp.

bool is_root ( ) const

True iff the node is the root of its Tree.

Definition at line 209 of file node.cpp.

TreeLink & link ( )

Return the TreeLink that points towards the root.

This is just an alias for primary_link(), that is shorter to use when needed frequently in an algorithm.

Definition at line 75 of file node.cpp.

TreeLink const & link ( ) const

Return the TreeLink that points towards the root.

This is just an alias for primary_link(), that is shorter to use when needed frequently in an algorithm.

Definition at line 86 of file node.cpp.

TreeNode& operator= ( TreeNode const &  )
delete
TreeNode& operator= ( TreeNode &&  )
delete
TreeLink & primary_link ( )

Return the TreeLink that points towards the root.

Definition at line 56 of file node.cpp.

TreeLink const & primary_link ( ) const

Return the TreeLink that points towards the root.

Definition at line 64 of file node.cpp.

size_t rank ( ) const

Rank of the node, i.e. how many immediate children it has.

Definition at line 176 of file node.cpp.

TreeNode & reset_data ( std::unique_ptr< BaseNodeData data)

Reset the data pointer of this TreeNode.

Using this function, a TreeNode can be assigend new data. It is also possible to change the data type completely (as long as it derives from BaseNodeData). Be however aware that many functions that work with trees expcet a certain data type. Thus, changing it might break those functions and lead to exceptions and other errors.

Definition at line 163 of file node.cpp.

TreeNode & reset_index ( size_t  val)

Reset the internal index of this TreeNode.

This is a helper function that needs to be used with care and only in cases where appropriate. The index is an invariant that needs to be kept, as it needs to match the index in the Tree container.

This function exists to allow building and modifying a Tree without the need for many friend declarations. However, the function should rarely be needed outside of this context.

Definition at line 135 of file node.cpp.

TreeNode & reset_primary_link ( TreeLink val)

Reset the internal pointer to the TreeLink of this TreeNode.

This is a helper function that needs to be used with care and only in cases where appropriate.

This function exists to allow building and modifying a Tree without the need for many friend declarations. However, the function should rarely be needed outside of this context.

Definition at line 149 of file node.cpp.

Friends And Related Function Documentation

friend class Tree
friend

Definition at line 64 of file node.hpp.


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