A toolkit for working with phylogenetic data.
v0.24.0
tree/common_tree/distances.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_TREE_COMMON_TREE_DISTANCES_H_
2 #define GENESIS_TREE_COMMON_TREE_DISTANCES_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
34 #include <vector>
35 
38 
39 namespace genesis {
40 namespace tree {
41 
42 // =================================================================================================
43 // Branch Distance Measures
44 // =================================================================================================
45 
52 utils::Matrix<double> node_branch_length_distance_matrix(
53  Tree const& tree
54 );
55 
66 std::vector<double> node_branch_length_distance_vector(
67  Tree const& tree,
68  TreeNode const* node = nullptr
69 );
70 
71 utils::Matrix<double> edge_branch_length_distance_matrix(
72  Tree const& tree
73 );
74 
75 std::vector<double> edge_branch_length_distance_vector(
76  Tree const& tree,
77  TreeEdge const* edge = nullptr
78 );
79 
80 // =================================================================================================
81 // Complex Distance Methods
82 // =================================================================================================
83 
87 double deepest_distance( Tree const& tree );
88 
100 std::vector<std::pair< TreeNode const*, double>> closest_leaf_distance_vector(
101  Tree const& tree
102 );
103 
104 std::vector<std::pair< TreeNode const*, double>> closest_leaf_distance_vector(
105  Tree const& tree,
106  utils::Matrix<double> const& node_branch_length_distance_mat
107 );
108 
112 std::vector<std::pair< TreeNode const*, double>> furthest_leaf_distance_vector(
113  Tree const& tree
114 );
115 
116 std::vector<std::pair< TreeNode const*, double>> furthest_leaf_distance_vector(
117  Tree const& tree,
118  utils::Matrix<double> const& node_branch_length_distance_mat
119 );
120 
121 } // namespace tree
122 } // namespace genesis
123 
124 #endif // include guard
double deepest_distance(Tree const &tree)
Return the longest distance from any point in the tree (on the edges) to any leaf.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
utils::Matrix< double > edge_branch_length_distance_matrix(Tree const &tree)
std::vector< std::pair< TreeNode const *, double > > closest_leaf_distance_vector(Tree const &tree)
Return a vector containing the closest leaf node for each node, using the branch_length as distance m...
std::vector< double > node_branch_length_distance_vector(Tree const &tree, TreeNode const *node)
Return a vector containing the distance of all nodes with respect to the given start node...
std::vector< double > edge_branch_length_distance_vector(Tree const &tree, TreeEdge const *edge)
std::vector< std::pair< TreeNode const *, double > > furthest_leaf_distance_vector(Tree const &tree)
Opposite of closest_leaf_distance_vector().
utils::Matrix< double > node_branch_length_distance_matrix(Tree const &tree)
Return a distance matrix containing pairwise distances between all Nodes, using the branch_length of ...