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 class
SharedNearestNeighborPreprocessor.Factory<O>
Factory class
-
Field Summary
Fields Modifier and Type Field Description protected Distance<O>
distance
Hold the distance function to be used.private static Logging
LOG
Get a logger for this class.protected int
numberOfNeighbors
Holds the number of nearest neighbors to be used.protected Relation<O>
relation
Relation to use.protected WritableDataStore<ArrayDBIDs>
storage
The 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 ArrayDBIDs
getNearestNeighborSet(DBIDRef objid)
Get the precomputed nearest neighborsint
getNumberOfNeighbors()
Get the number of neighborsvoid
initialize()
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:Index
Initialize the index. For static indexes, this is the moment the index is bulk loaded.- Specified by:
initialize
in interfaceIndex
-
getNearestNeighborSet
public ArrayDBIDs getNearestNeighborSet(DBIDRef objid)
Description copied from interface:SharedNearestNeighborIndex
Get the precomputed nearest neighbors- Specified by:
getNearestNeighborSet
in interfaceSharedNearestNeighborIndex<O>
- Parameters:
objid
- Object ID- Returns:
- Neighbor DBIDs
-
getNumberOfNeighbors
public int getNumberOfNeighbors()
Get the number of neighbors- Specified by:
getNumberOfNeighbors
in interfaceSharedNearestNeighborIndex<O>
- Returns:
- NN size
-
-