de.lmu.ifi.dbs.elki.index.preprocessed.snn
Class SharedNearestNeighborPreprocessor<O,D extends Distance<D>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.index.AbstractIndex<O>
      extended by de.lmu.ifi.dbs.elki.index.preprocessed.AbstractPreprocessorIndex<O,TreeSetDBIDs>
          extended by de.lmu.ifi.dbs.elki.index.preprocessed.snn.SharedNearestNeighborPreprocessor<O,D>
Type Parameters:
O - the type of database objects the preprocessor can be applied to
D - the type of distance the used distance function will return
All Implemented Interfaces:
Index, SharedNearestNeighborIndex<O>, Result

@Title(value="Shared nearest neighbor Preprocessor")
@Description(value="Computes the k nearest neighbors of objects of a certain database.")
public class SharedNearestNeighborPreprocessor<O,D extends Distance<D>>
extends AbstractPreprocessorIndex<O,TreeSetDBIDs>
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.


Nested Class Summary
static class SharedNearestNeighborPreprocessor.Factory<O,D extends Distance<D>>
          Factory class
 
Field Summary
protected  DistanceFunction<O,D> distanceFunction
          Hold the distance function to be used.
private static Logging logger
          Get a logger for this class.
protected  int numberOfNeighbors
          Holds the number of nearest neighbors to be used.
 
Fields inherited from class de.lmu.ifi.dbs.elki.index.preprocessed.AbstractPreprocessorIndex
storage
 
Fields inherited from class de.lmu.ifi.dbs.elki.index.AbstractIndex
relation
 
Constructor Summary
SharedNearestNeighborPreprocessor(Relation<O> relation, int numberOfNeighbors, DistanceFunction<O,D> distanceFunction)
          Constructor.
 
Method Summary
protected  Logging getLogger()
          Get the classes static logger.
 String getLongName()
          A "pretty" name for the result, for use in titles, captions and menus.
 TreeSetDBIDs getNearestNeighborSet(DBID objid)
          Get the precomputed nearest neighbors
 int getNumberOfNeighbors()
          Get the number of neighbors
 String getShortName()
          A short name for the result, useful for file names.
protected  void preprocess()
          Preprocessing step.
 
Methods inherited from class de.lmu.ifi.dbs.elki.index.AbstractIndex
delete, deleteAll, getPageFileStatistics, insert, insertAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.index.Index
delete, deleteAll, getPageFileStatistics, insert, insertAll
 

Field Detail

logger

private static final Logging logger
Get a logger for this class.


numberOfNeighbors

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


distanceFunction

protected DistanceFunction<O,D extends Distance<D>> distanceFunction
Hold the distance function to be used.

Constructor Detail

SharedNearestNeighborPreprocessor

public SharedNearestNeighborPreprocessor(Relation<O> relation,
                                         int numberOfNeighbors,
                                         DistanceFunction<O,D> distanceFunction)
Constructor.

Parameters:
relation - Database to use
numberOfNeighbors - Number of neighbors
distanceFunction - Distance function
Method Detail

preprocess

protected void preprocess()
Preprocessing step.


getNearestNeighborSet

public TreeSetDBIDs getNearestNeighborSet(DBID objid)
Description copied from interface: SharedNearestNeighborIndex
Get the precomputed nearest neighbors

Specified by:
getNearestNeighborSet in interface SharedNearestNeighborIndex<O>
Parameters:
objid - Object ID
Returns:
Neighbor DBIDs

getLogger

protected Logging getLogger()
Description copied from class: AbstractPreprocessorIndex
Get the classes static logger.

Specified by:
getLogger in class AbstractPreprocessorIndex<O,TreeSetDBIDs>
Returns:
Logger

getLongName

public String getLongName()
Description copied from interface: Result
A "pretty" name for the result, for use in titles, captions and menus.

Specified by:
getLongName in interface Result
Specified by:
getLongName in class AbstractIndex<O>
Returns:
result name

getShortName

public String getShortName()
Description copied from interface: Result
A short name for the result, useful for file names.

Specified by:
getShortName in interface Result
Specified by:
getShortName in class AbstractIndex<O>
Returns:
result name

getNumberOfNeighbors

public int getNumberOfNeighbors()
Get the number of neighbors

Specified by:
getNumberOfNeighbors in interface SharedNearestNeighborIndex<O>
Returns:
NN size

Release 0.4.0 (2011-09-20_1324)