org.hermit.geometry.cluster
Class Clusterer

java.lang.Object
  extended by org.hermit.geometry.cluster.Clusterer
Direct Known Subclasses:
FuzzyClusterer, KMeansClusterer

public abstract class Clusterer
extends java.lang.Object

A generic interface to a clustering algorithm.


Constructor Summary
Clusterer()
           
 
Method Summary
abstract  boolean iterate()
          Runs a single iteration of the clustering algorithm on the stored data.
abstract  double metric()
          Calculate a quality metric for the current clustering solution.
 void prepare(Point[] points, int[] ids, double[][] means, Region region)
          Prepare a clustering pass on the indicated data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clusterer

public Clusterer()
Method Detail

prepare

public void prepare(Point[] points,
                    int[] ids,
                    double[][] means,
                    Region region)
Prepare a clustering pass on the indicated data.

Subclasses can override this to do their own preparation, but must call through to this method.

Parameters:
points - The array of points to be clustered.
ids - Array of cluster numbers which this call will fill in, defining which cluster each point belongs to. The caller must leave the data here intact between iterations.
means - Array of x,y values in which to place centroids of the clusters.
region - The region of the plane in which the points lie.

iterate

public abstract boolean iterate()
Runs a single iteration of the clustering algorithm on the stored data. The results are stored in the arrays that were passed into prepare(Point[], int[], double[][], Region).

After each iteration, the cluster IDs and cluster means should be consistent with each other.

Returns:
true if the algorithm has converged.

metric

public abstract double metric()
Calculate a quality metric for the current clustering solution. This number is available after each call to iterate().

Returns:
Quality metric for this solution; small is better.