-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcluster.cpp
More file actions
60 lines (50 loc) · 1.43 KB
/
cluster.cpp
File metadata and controls
60 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by kevangel on 22/11/18.
//
#include "cluster.h"
cluster::cluster(data_point<double> d) {
set_centroid(d);
}
void cluster::set_centroid(data_point<double> cen){
this->centroid=cen;
}
data_point<double> cluster::get_centroid(){
return this->centroid;
}
void cluster::add_item(data_point<double> item){
this->clitems.push_back(item);
}
vector<data_point<double>> cluster::get_items(){
return this->clitems;
}
void cluster::empty_clitems() {
this->clitems.clear();
}
void cluster::print_centroid() {
cout << "Item: " << centroid.name << " Size: " << centroid.point.size() << endl;
for (int i = 0 ; i< centroid.point.size(); i++){
cout << centroid.point[i] << " " ;
}
cout <<endl;
}
void cluster::print_cluster() {
cout << "Centroid: " << this->centroid.name << endl;
cout << "Cluster Size: " << this->clitems.size() << endl;
for (int i = 0 ; i< this->clitems.size() ; i++){
cout << this->clitems[i].name << endl ;
for (int j=0;j<this->clitems[i].point.size();j++)
cout << this->clitems[i].point[j] << " ";
cout <<endl;
}
cout <<endl;
}
int cluster::check_equal(cluster xx) {
if(this->clitems.size()!=xx.clitems.size()) return 0;
vector<data_point<double>> zz=xx.get_items();
for (int i=0; i< this->clitems.size();i++){
if (this->clitems[i].point!=zz[i].point){
return 0;
}
}
return 1;
}