IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
PartitionalClusteringWithCenter.h
Go to the documentation of this file.
1/**
2 * \file IMP/statistics/PartitionalClusteringWithCenter.h
3 * \brief Cluster sets of points.
4 *
5 * Copyright 2007-2026 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H
10#define IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H
11
12#include <IMP/statistics/statistics_config.h>
14
15IMPSTATISTICS_BEGIN_NAMESPACE
16/** In addition to the information in the Clustering base class,
17 PartitionalClusteringWithCenter stores a cluster center for
18 each cluster.
19 The cluster center is a point in the space defined by the
20 embedding.
21
22 The representative for each cluster is the member whose
23 location in the embedding is closest to the cluster center.
24*/
25class IMPSTATISTICSEXPORT PartitionalClusteringWithCenter
26 : public PartitionalClustering {
27 IMP::Vector<Ints> clusters_;
28 Ints reps_;
29 algebra::VectorKDs centers_;
30
31 public:
32#if !defined(SWIG) && !defined(IMP_DOXYGEN)
33 template <int D>
35 const IMP::Vector<Ints> &clusters,
36 const IMP::Vector<algebra::VectorD<D>> &centers, const Ints &reps)
37 : PartitionalClustering("k-means"),
38 clusters_(clusters),
39 reps_(reps),
40 centers_(reps.size()) {
41 for (unsigned int i = 0; i < centers_.size(); ++i) {
42 centers_[i] = algebra::VectorKD(centers[i].begin(), centers[i].end());
43 }
44 }
45#endif
46 const algebra::VectorKD &get_cluster_center(unsigned int i) const {
47 return centers_[i];
48 }
49 unsigned int get_number_of_clusters() const override;
50 const Ints &get_cluster(unsigned int i) const override;
51 int get_cluster_representative(unsigned int i) const override;
52
54};
55
56IMPSTATISTICS_END_NAMESPACE
57
58#endif /* IMPSTATISTICS_PARTITIONAL_CLUSTERING_WITH_CENTER_H */
Compute a distance metric between two points.
A Cartesian vector in D-dimensions.
Definition VectorD.h:38
A more IMP-like version of the std::vector.
Definition Vector.h:60
const Ints & get_cluster(unsigned int i) const override
Return the list of indexes in the ith cluster.
int get_cluster_representative(unsigned int i) const override
Return the index of an item that "typifies" the ith cluster.
Vector< VectorD<-1 > > VectorKDs
Definition VectorD.h:425
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
Definition types.h:48
VectorD<-1 > VectorKD
Definition VectorD.h:423
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.