A library for working with phylogenetic and population genetic data.
v0.32.0
tree/mass_tree/kmeans.hpp
Go to the documentation of this file.
1
#ifndef GENESIS_TREE_MASS_TREE_KMEANS_H_
2
#define GENESIS_TREE_MASS_TREE_KMEANS_H_
3
4
/*
5
Genesis - A toolkit for working with phylogenetic data.
6
Copyright (C) 2014-2019 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 "
genesis/utils/math/kmeans.hpp
"
35
36
namespace
genesis
{
37
namespace
tree {
38
39
// =================================================================================================
40
// Forward Declarations
41
// =================================================================================================
42
43
class
Tree;
44
class
TreeNode;
45
class
TreeEdge;
46
47
using
MassTree
= Tree;
48
49
// =================================================================================================
50
// Mass Tree Kmeans
51
// =================================================================================================
52
53
class
MassTreeKmeans
54
:
public
utils::Kmeans
< MassTree >
55
{
56
public
:
57
58
// -------------------------------------------------------------------------
59
// Typedefs and Constants
60
// -------------------------------------------------------------------------
61
62
using
Point
=
MassTree
;
63
64
// -------------------------------------------------------------------------
65
// Constructors and Rule of Five
66
// -------------------------------------------------------------------------
67
68
MassTreeKmeans
() =
default
;
69
virtual
~MassTreeKmeans
()
override
=
default
;
70
71
MassTreeKmeans
(
MassTreeKmeans
const
& ) =
default
;
72
MassTreeKmeans
(
MassTreeKmeans
&& ) =
default
;
73
74
MassTreeKmeans
&
operator=
(
MassTreeKmeans
const
& ) =
default
;
75
MassTreeKmeans
&
operator=
(
MassTreeKmeans
&& ) =
default
;
76
77
// -------------------------------------------------------------------------
78
// Settings
79
// -------------------------------------------------------------------------
80
81
size_t
accumulate_centroid_masses
()
const
;
82
void
accumulate_centroid_masses
(
size_t
value );
83
84
// -------------------------------------------------------------------------
85
// Default K-Means Functions
86
// -------------------------------------------------------------------------
87
88
private
:
89
90
virtual
void
pre_loop_hook(
91
std::vector<Point>
const
& data,
92
std::vector<size_t>&
assignments
,
93
std::vector<Point>&
centroids
94
)
override
;
95
96
virtual
bool
data_validation( std::vector<Point>
const
& data )
const override
;
97
98
virtual
void
update_centroids(
99
std::vector<Point>
const
& data,
100
std::vector<size_t>
const
&
assignments
,
101
std::vector<Point>&
centroids
102
)
override
;
103
104
virtual
double
distance(
Point
const
& lhs,
Point
const
& rhs )
const override
;
105
106
// -------------------------------------------------------------------------
107
// Data
108
// -------------------------------------------------------------------------
109
110
size_t
accumulate_centroid_masses_ = 1;
111
112
};
113
114
}
// namespace tree
115
}
// namespace genesis
116
117
#endif // include guard
genesis::tree::MassTree
Tree MassTree
Alias for a Tree that stores masses on its TreeEdges.
Definition:
placement/function/operators.hpp:54
genesis::utils::Kmeans< MassTree >::assignments
std::vector< size_t > const & assignments() const
Definition:
utils/math/kmeans.hpp:174
genesis::utils::Kmeans
Definition:
utils/math/kmeans.hpp:91
genesis::tree::Tree
Class for representing phylogenetic trees.
Definition:
tree/tree.hpp:97
kmeans.hpp
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition:
placement/formats/edge_color.cpp:42
genesis::tree::MassTreeKmeans::MassTreeKmeans
MassTreeKmeans()=default
genesis::tree::MassTreeKmeans::~MassTreeKmeans
virtual ~MassTreeKmeans() override=default
genesis::utils::Kmeans< MassTree >::centroids
std::vector< MassTree > const & centroids() const
Definition:
utils/math/kmeans.hpp:185
genesis::tree::MassTreeKmeans
Definition:
tree/mass_tree/kmeans.hpp:53
genesis::tree::MassTreeKmeans::operator=
MassTreeKmeans & operator=(MassTreeKmeans const &)=default
genesis::tree::MassTreeKmeans::accumulate_centroid_masses
size_t accumulate_centroid_masses() const
Definition:
kmeans.cpp:54
lib
genesis
tree
mass_tree
kmeans.hpp
Generated on Mon Aug 5 2024 16:57:52 for genesis by
1.8.17