ʻOhana
Population structure, admixture history, and selection using learning methods.
Public Types | Public Member Functions
jade::basic_tree_path< TValue > Class Template Reference

A template for a class that maintains a table of nodes indicating a distance to the root of the tree. More...

#include <jade.tree_path.hpp>

+ Inheritance diagram for jade::basic_tree_path< TValue >:
+ Collaboration diagram for jade::basic_tree_path< TValue >:

Public Types

typedef TValue value_type
 The value type. More...
 
typedef basic_newick_node< value_typenode_type
 The Newick node type. More...
 

Public Member Functions

 basic_tree_path (const node_type &node)
 Initializes a new instance of the class by computing the set of nodes in the path to the root. The specified node is included in the result, but the root node is not. For example, computing a tree path for node 'D' for the tree, "((B:2,(C:4,D:5)n1:3)n2:1)A;" results in the container (D, n1, n2). More...
 
value_type get_length () const
 
basic_tree_path operator& (const basic_tree_path &rhs) const
 Computes the overlapped tree path of this instance and another instance. This method returns only the nodes that exist in both containers. More...
 

Detailed Description

template<typename TValue>
class jade::basic_tree_path< TValue >

A template for a class that maintains a table of nodes indicating a distance to the root of the tree.

Definition at line 19 of file jade.tree_path.hpp.

Member Typedef Documentation

◆ node_type

template<typename TValue >
typedef basic_newick_node<value_type> jade::basic_tree_path< TValue >::node_type

The Newick node type.

Definition at line 26 of file jade.tree_path.hpp.

◆ value_type

template<typename TValue >
typedef TValue jade::basic_tree_path< TValue >::value_type

The value type.

Definition at line 23 of file jade.tree_path.hpp.

Constructor & Destructor Documentation

◆ basic_tree_path()

template<typename TValue >
jade::basic_tree_path< TValue >::basic_tree_path ( const node_type node)
inlineexplicit

Initializes a new instance of the class by computing the set of nodes in the path to the root. The specified node is included in the result, but the root node is not. For example, computing a tree path for node 'D' for the tree, "((B:2,(C:4,D:5)n1:3)n2:1)A;" results in the container (D, n1, n2).

Parameters
nodeThe node to measure.

Definition at line 43 of file jade.tree_path.hpp.

45  : _map ()
46  {
47  //
48  // Loop toward the root node, starting at the specified node, but
49  // do not include the root node in the result; in each iteration,
50  // accumulate the nodes traversed.
51  //
52  for (auto n = &node; !n->is_root(); n = n->get_parent())
53  _map[n->get_id()] = n;
54  }

Member Function Documentation

◆ get_length()

template<typename TValue >
value_type jade::basic_tree_path< TValue >::get_length ( ) const
inline
Returns
The sum of the lengths for all nodes of this instance.

Definition at line 59 of file jade.tree_path.hpp.

60  {
61  auto sum = value_type(0);
62  for (const auto & pair : _map)
63  sum += pair.second->get_length();
64  return sum;
65  }
+ Here is the caller graph for this function:

◆ operator&()

template<typename TValue >
basic_tree_path jade::basic_tree_path< TValue >::operator& ( const basic_tree_path< TValue > &  rhs) const
inline

Computes the overlapped tree path of this instance and another instance. This method returns only the nodes that exist in both containers.

Returns
A new tree path.
Parameters
rhsThe other tree path.

Definition at line 74 of file jade.tree_path.hpp.

77  {
78  basic_tree_path p;
79 
80  for (const auto & pair: rhs._map)
81  if (_map.find(pair.first) != _map.end())
82  p._map[pair.first] = pair.second;
83 
84  return p;
85  }

The documentation for this class was generated from the following file:
jade::basic_tree_path::value_type
TValue value_type
The value type.
Definition: jade.tree_path.hpp:23