Class GvmClusters<S extends GvmSpace,​K>

  • Type Parameters:
    K - the key type

    public class GvmClusters<S extends GvmSpace,​K>
    extends Object
    Maintains a collection of clusters which are adjusted as new elements are added. The keyer assigned to this object should not be modified while there are clusters.
    Author:
    Tom Gibara
    • Constructor Detail

      • GvmClusters

        public GvmClusters​(S space,
                           int capacity)
    • Method Detail

      • getKeyer

        public GvmKeyer<K> getKeyer()
        The keyer used to assign keys to clusters.
      • setKeyer

        public void setKeyer​(GvmKeyer<K> keyer)
        The keyer to be used.
        Parameters:
        keyer - a keyer, not null
      • getCapacity

        public int getCapacity()
        The greatest number of clusters that may be recorded.
        Returns:
        the capacity
      • getSpace

        public S getSpace()
        The space in which clustering will be performed
        Returns:
        the space containing the points to be clustered
      • clear

        public void clear()
        Removes all clusters and clustered points but retains the keyer.
      • add

        public void add​(double m,
                        Object pt,
                        K key)
        Adds a point to be clustered.
        Parameters:
        m - the mass at the point
        xs - the coordinates of the point
        key - a key assigned to the point, may be null
      • reduce

        public void reduce​(double maxVar,
                           int minClusters)
        Collapses the number of clusters subject to constraints on the maximum permitted variance, and the least number of clusters. This method may be called at any time, including between calls to add().
        Parameters:
        maxVar - an upper bound on the global variance that may not be exceeded by merging clusters
        minClusters - a lower bound on the the number of clusters that may not be exceeded by merging clusters
      • results

        public List<GvmResult<K>> results()
        Obtains the clusters for the points added. This method may be called at any time, including between calls to add().
        Returns:
        the result of clustering the points thus far added