Class Point

  • All Implemented Interfaces:
    java.lang.Comparable<Point>

    public final class Point
    extends java.lang.Object
    implements java.lang.Comparable<Point>
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Point.Factory
      Primarily used when constructing test cases and similar.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      float[] coordinates  
      int id  
    • Constructor Summary

      Constructors 
      Constructor Description
      Point​(int id, float[] coordinates)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.util.Set<Point>> cluster​(java.util.Collection<Point> input)
      Essentially works like this: Calculate, and store, distances between all the points (to enable statistical analysis, and speed up the following steps) Perform statistical analysis of the distances to determine a suitable distance threshold for greedy clustering Perform greedy clustering to get an initial set of centroids Filter out centroids/clusters corresponding to extremely small clusters (This determines the 'k') Perform k-means clustering to refine the clusters and centroids
      int compareTo​(Point ref)  
      static <T> java.util.List<Point> convert​(java.util.List<T> input, java.util.function.Function<T,​float[]> converter)
      Converts a list of objects to a list of points using the provided converter to derive the coordinates.
      double distance​(Point other)
      The sum of the squared differences between the coordinates of this and the other point.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      static Point mean​(java.util.Collection<Point> points)  
      static Point.Factory newFactory​(int dimensions)  
      static ClusteringAlgorithm<Point> newGreedyClusterer​(double distanceThreshold)
      Greedy algorithm.
      static ClusteringAlgorithm<Point> newKMeansClusterer​(int k)
      Standard k-means clustering
      static Point of​(int id, float... coordinates)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • coordinates

        public final float[] coordinates
      • id

        public final int id
    • Constructor Detail

      • Point

        Point​(int id,
              float[] coordinates)
    • Method Detail

      • cluster

        public static java.util.List<java.util.Set<Point>> cluster​(java.util.Collection<Point> input)
        Essentially works like this:
        1. Calculate, and store, distances between all the points (to enable statistical analysis, and speed up the following steps)
        2. Perform statistical analysis of the distances to determine a suitable distance threshold for greedy clustering
        3. Perform greedy clustering to get an initial set of centroids
        4. Filter out centroids/clusters corresponding to extremely small clusters (This determines the 'k')
        5. Perform k-means clustering to refine the clusters and centroids
      • convert

        public static <T> java.util.List<Point> convert​(java.util.List<T> input,
                                                        java.util.function.Function<T,​float[]> converter)
        Converts a list of objects to a list of points using the provided converter to derive the coordinates. There will be one point for each object in the input list, at matching positions. Further the point id will be the index of the object in the input list.
        Type Parameters:
        T - The type of the objects in the input list
        Parameters:
        input - The list of objects to convert
        converter - The function to convert the objects to coordinates
        Returns:
        A list of points
      • mean

        public static Point mean​(java.util.Collection<Point> points)
      • newFactory

        public static Point.Factory newFactory​(int dimensions)
      • newGreedyClusterer

        public static ClusteringAlgorithm<Point> newGreedyClusterer​(double distanceThreshold)
        Greedy algorithm. The distance measurement is the same as for k-means (distance(Point)) and the threshold must match that.
      • newKMeansClusterer

        public static ClusteringAlgorithm<Point> newKMeansClusterer​(int k)
        Standard k-means clustering
      • of

        public static Point of​(int id,
                               float... coordinates)
      • compareTo

        public int compareTo​(Point ref)
        Specified by:
        compareTo in interface java.lang.Comparable<Point>
      • distance

        public double distance​(Point other)
        The sum of the squared differences between the coordinates of this and the other point. (Not the Euclidean distance. This is the squared Euclidean distance.)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object