A library for working with phylogenetic and population genetic data.
v0.32.0
Subtree Class Reference

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

Detailed Description

Reference to a subtree of a Tree.

This class refers to a particular subtree of a Tree. Such a subtree contains all TreeNodes and TreeEdges at one side of a TreeEdge, while leaving out the other side of it.

The "subtree" of a leaf node is only that node itself. There are no empty subtrees, and there is no subtree that contains all of the Tree. That is, a Subtree is always a split (or bipartition) of the Tree into two parts, separated by an edge.

A subtree is defined by the TreeLink that is part of the subtree, while its outer() link is not:

Subtree given by a TreeLink.

In the example, parts A and B, as well as the node on the left, belong to the Subtree, and parts C and D, as well as the node on the right do not.

The marked TreeLink, as well as its TreeNode and TreeEdge can be used to construct a Subtree and can be retrieved from it. The Tree that a Subtree refers to has to stay alive, otherwise we get dangling pointers. It is the responsibility of the user to ensure this.

The Tree iterators (e.g., IteratorPreorder and IteratorPostorder) furthermore offer constructors that take a Subtree and only iterate this part of the Tree.

Definition at line 69 of file subtree.hpp.

Public Member Functions

 Subtree (Subtree &&)=default
 
 Subtree (Subtree const &)=default
 
 Subtree (TreeEdge const &edge, bool use_primary=false)
 Construct a Subtree in one of the two directions of a given TreeEdge. More...
 
 Subtree (TreeLink const &link)
 Construct a Subtree that contains all of the tree except for the part that the outer() link of the given TreeLink belongs to. More...
 
 Subtree (TreeNode const &node)
 Construct a Subtree representing the given TreeNode and the part of the Tree away from its root node. More...
 
 ~Subtree ()=default
 
TreeEdge const & edge () const
 Get the TreeEdge that separates the subtree from the rest of the tree. More...
 
void invert ()
 Invert/flip the subtree to represent the other (complementary) part of the tree. More...
 
TreeLink const & link () const
 Get the TreeLink that separates the subtree from the rest of the tree. More...
 
TreeNode const & node () const
 Get the TreeNode at which the subtree starts. More...
 
Subtreeoperator= (Subtree &&)=default
 
Subtreeoperator= (Subtree const &)=default
 

Protected Attributes

TreeLink const * link_ = nullptr
 

Constructor & Destructor Documentation

◆ Subtree() [1/5]

Subtree ( TreeLink const &  link)
inlineexplicit

Construct a Subtree that contains all of the tree except for the part that the outer() link of the given TreeLink belongs to.

Definition at line 86 of file subtree.hpp.

◆ Subtree() [2/5]

Subtree ( TreeNode const &  node)
inlineexplicit

Construct a Subtree representing the given TreeNode and the part of the Tree away from its root node.

Definition at line 94 of file subtree.hpp.

◆ Subtree() [3/5]

Subtree ( TreeEdge const &  edge,
bool  use_primary = false 
)
inline

Construct a Subtree in one of the two directions of a given TreeEdge.

With use_primary set to false (default), the subtree is the one pointing away from the root. With use_primary set to true, the root side of the edge is used as subtree instead.

Definition at line 104 of file subtree.hpp.

◆ ~Subtree()

~Subtree ( )
default

◆ Subtree() [4/5]

Subtree ( Subtree const &  )
default

◆ Subtree() [5/5]

Subtree ( Subtree &&  )
default

Member Function Documentation

◆ edge()

TreeEdge const& edge ( ) const
inline

Get the TreeEdge that separates the subtree from the rest of the tree.

Definition at line 141 of file subtree.hpp.

◆ invert()

void invert ( )
inline

Invert/flip the subtree to represent the other (complementary) part of the tree.

Definition at line 149 of file subtree.hpp.

◆ link()

TreeLink const& link ( ) const
inline

Get the TreeLink that separates the subtree from the rest of the tree.

This link belongs to the subtree, while its outer() does not.

Definition at line 125 of file subtree.hpp.

◆ node()

TreeNode const& node ( ) const
inline

Get the TreeNode at which the subtree starts.

Definition at line 133 of file subtree.hpp.

◆ operator=() [1/2]

Subtree& operator= ( Subtree &&  )
default

◆ operator=() [2/2]

Subtree& operator= ( Subtree const &  )
default

Member Data Documentation

◆ link_

TreeLink const* link_ = nullptr
protected

Definition at line 168 of file subtree.hpp.


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