Class SharedNearestNeighborPreprocessor<O>

  • Type Parameters:
    O - the type of database objects the preprocessor can be applied to
    All Implemented Interfaces:
    elki.index.Index, SharedNearestNeighborIndex<O>

    @Title("Shared Nearest Neighbor Preprocessor")
    @Description("Computes the k nearest neighbors of objects of a certain database.")
    public class SharedNearestNeighborPreprocessor<O>
    extends java.lang.Object
    implements SharedNearestNeighborIndex<O>
    A preprocessor for annotation of the ids of nearest neighbors to each database object.

    The k nearest neighbors are assigned based on an arbitrary distance function.

    This functionality is similar but not identical to MaterializeKNNPreprocessor: While it also computes the k nearest neighbors, it does not keep the actual distances, but organizes the NN set in a TreeSet for fast set operations.

    Since:
    0.1
    Author:
    Arthur Zimek, Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected elki.distance.Distance<O> distance
      Hold the distance function to be used.
      private static elki.logging.Logging LOG
      Get a logger for this class.
      protected int numberOfNeighbors
      Holds the number of nearest neighbors to be used.
      protected elki.database.relation.Relation<O> relation
      Relation to use.
      protected elki.database.datastore.WritableDataStore<elki.database.ids.ArrayDBIDs> storage
      The data store.
    • Constructor Summary

      Constructors 
      Constructor Description
      SharedNearestNeighborPreprocessor​(elki.database.relation.Relation<O> relation, int numberOfNeighbors, elki.distance.Distance<O> distance)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      elki.database.ids.ArrayDBIDs getNearestNeighborSet​(elki.database.ids.DBIDRef objid)
      Get the precomputed nearest neighbors
      int getNumberOfNeighbors()
      Get the number of neighbors
      void initialize()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface elki.index.Index

        logStatistics
    • Field Detail

      • LOG

        private static final elki.logging.Logging LOG
        Get a logger for this class.
      • numberOfNeighbors

        protected int numberOfNeighbors
        Holds the number of nearest neighbors to be used.
      • distance

        protected elki.distance.Distance<O> distance
        Hold the distance function to be used.
      • storage

        protected elki.database.datastore.WritableDataStore<elki.database.ids.ArrayDBIDs> storage
        The data store.
      • relation

        protected elki.database.relation.Relation<O> relation
        Relation to use.
    • Constructor Detail

      • SharedNearestNeighborPreprocessor

        public SharedNearestNeighborPreprocessor​(elki.database.relation.Relation<O> relation,
                                                 int numberOfNeighbors,
                                                 elki.distance.Distance<O> distance)
        Constructor.
        Parameters:
        relation - Database to use
        numberOfNeighbors - Number of neighbors
        distance - Distance function
    • Method Detail

      • initialize

        public void initialize()
        Specified by:
        initialize in interface elki.index.Index