Package elki.index.preprocessed.snn
Class SharedNearestNeighborPreprocessor<O>
- java.lang.Object
-
- elki.index.preprocessed.snn.SharedNearestNeighborPreprocessor<O>
-
- Type Parameters:
O- the type of database objects the preprocessor can be applied to
- All Implemented Interfaces:
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSharedNearestNeighborPreprocessor.Factory<O>Factory class
-
Field Summary
Fields Modifier and Type Field Description protected Distance<O>distanceHold the distance function to be used.private static LoggingLOGGet a logger for this class.protected intnumberOfNeighborsHolds the number of nearest neighbors to be used.protected Relation<O>relationRelation to use.protected WritableDataStore<ArrayDBIDs>storageThe data store.
-
Constructor Summary
Constructors Constructor Description SharedNearestNeighborPreprocessor(Relation<O> relation, int numberOfNeighbors, Distance<O> distance)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayDBIDsgetNearestNeighborSet(DBIDRef objid)Get the precomputed nearest neighborsintgetNumberOfNeighbors()Get the number of neighborsvoidinitialize()Initialize the index.-
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 Logging LOG
Get a logger for this class.
-
numberOfNeighbors
protected int numberOfNeighbors
Holds the number of nearest neighbors to be used.
-
storage
protected WritableDataStore<ArrayDBIDs> storage
The data store.
-
-
Method Detail
-
initialize
public void initialize()
Description copied from interface:IndexInitialize the index. For static indexes, this is the moment the index is bulk loaded.- Specified by:
initializein interfaceIndex
-
getNearestNeighborSet
public ArrayDBIDs getNearestNeighborSet(DBIDRef objid)
Description copied from interface:SharedNearestNeighborIndexGet the precomputed nearest neighbors- Specified by:
getNearestNeighborSetin interfaceSharedNearestNeighborIndex<O>- Parameters:
objid- Object ID- Returns:
- Neighbor DBIDs
-
getNumberOfNeighbors
public int getNumberOfNeighbors()
Get the number of neighbors- Specified by:
getNumberOfNeighborsin interfaceSharedNearestNeighborIndex<O>- Returns:
- NN size
-
-