11#include <unordered_map>
14#ifndef VERBOSITY_LEVEL
15#define VERBOSITY_LEVEL 0
31 Eigen::VectorXi allocations;
35 std::unordered_map<int, std::vector<int>> cluster_members;
41 void compact_cluster(
int old_cluster);
50 Data(
const Eigen::MatrixXd &distances,
51 const Eigen::VectorXi &initial_allocations = Eigen::VectorXi());
87 return (cluster_index < K &&
88 cluster_members.find(cluster_index) != cluster_members.end())
89 ? cluster_members.at(cluster_index).size()
100 if (index < 0 || index >= n) {
101 throw std::out_of_range(
"Index out of bounds in get_cluster_assignment");
103 return allocations(index);
void set_allocation(int index, int cluster)
Assigns a point to a cluster.
Definition Data.cpp:103
int get_cluster_assignment(int index) const
Gets the cluster assignment of a specific point.
Definition Data.hpp:99
int get_n() const
Gets the total number of points.
Definition Data.hpp:67
int get_cluster_size(unsigned cluster_index) const
Gets the size of a specific cluster.
Definition Data.hpp:86
Data(const Eigen::MatrixXd &distances, const Eigen::VectorXi &initial_allocations=Eigen::VectorXi())
Constructs a Data object with a distance matrix.
Definition Data.cpp:10
const Eigen::VectorXi & get_allocations() const
Gets the cluster allocations vector.
Definition Data.hpp:79
void set_allocations(const Eigen::VectorXi &new_allocations)
Sets all cluster allocations at once.
Definition Data.cpp:180
double get_distance(int i, int j) const
Gets the distance between two points.
Definition Data.cpp:41
int get_K() const
Gets the current number of clusters.
Definition Data.hpp:73
Eigen::VectorXi get_cluster_assignments(int cluster) const
Gets all point indices assigned to a specific cluster.
Definition Data.cpp:51