* Executes the clustering algorithm. Use setters or constructor to prepare input data.
*/
@Override
public void perform()
{
DataList centroids = new DataList();
Iterator<IDoubleArray> it = data.iterator();
if (datasize > 0)
{
// take first element as centroid
centroids.add(it.next());
}
else
{
throw new RuntimeException("No first element .... aborting.");
}
IDoubleArray current;
while(it.hasNext())
{
current = it.next();
double[] d = calculateDistances(centroids, current, metric);
int minIndex = minIndex(d);
if (d[minIndex] >= dmin)
{
centroids.add(current);
System.out.println(d[minIndex] + "\t" + centroids.size());
}
}
this.clusterCenters = centroids;
this.voronoiPartitioning = new VoronoiDiscretization(this.clusterCenters, this.metric);