-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCluster.java
48 lines (37 loc) · 1.14 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
package YelpProject;
import java.util.ArrayList;
import java.util.Random;
public class Cluster {
//using K-means clustering
Point centroid;
ArrayList<Point> points;
int clusterID;
public Cluster( int clusterID ) {
this.centroid = null;
this.clusterID = clusterID;
this.points = new ArrayList<Point>();
}
public void setCentroid( Point c ) {
centroid = c;
}
public void addPoint( Point p ) {
points.add( p );
}
public ArrayList<Point> getCluster() {
return points;
}
public void printCluster() {
System.out.println( "Cluster: " + clusterID );
System.out.println( "CentroidX: " + centroid.x );
System.out.println( "CentroidY: " + centroid.y );
System.out.println( "Points: " );
for( Point p : points ) {
System.out.println( p.b.businessID );
System.out.println( p.b.businessName );
System.out.println( p.x );
System.out.println( p.y );
System.out.println("\n");
}
System.out.println("\n");
}
}