-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCluster.java
60 lines (50 loc) · 1.26 KB
/
Cluster.java
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
import java.util.ArrayList;
import java.util.List;
public class Cluster {
public ArrayList<Point> points;
public Point centroid;
public int id;
public static ArrayList<ArrayList<Point>> clusterList=new ArrayList<ArrayList<Point>>();
public static ArrayList<Point> clusterCentroids=new ArrayList<Point>();
//Creates a new Cluster
public Cluster(int id) {
this.id = id;
this.points = new ArrayList();
this.centroid = null;
}
public List getPoints() {
return points;
}
public void addPoint(Point point) {
points.add(point);
}
public void setPoints(ArrayList points) {
this.points = points;
}
public Point getCentroid() {
return centroid;
}
public void setCentroid(Point centroid) {
this.centroid = centroid;
}
public int getId() {
return id;
}
public void clear() {
points.clear();
}
/*
* Adds the points to their respective clusters
*/
public void plotCluster() {
// System.out.println("[Cluster: " + id+"]");
// System.out.println("[Centroid: " + centroid + "]");
// System.out.println("[Points: ");
clusterCentroids.add(id,centroid);
clusterList.add(id,points);
for(Point p : points) {
// System.out.println(p);
}
// System.out.println("]");
}
}