de.lmu.ifi.dbs.elki.algorithm
Class KNNJoin<V extends NumberVector<V,?>,D extends Distance<D>,N extends SpatialNode<N,E>,E extends SpatialEntry>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm<R>
      extended by de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm<V,D,DataStore<KNNList<D>>>
          extended by de.lmu.ifi.dbs.elki.algorithm.KNNJoin<V,D,N,E>
Type Parameters:
V - the type of FeatureVector handled by this Algorithm
D - the type of Distance used by this Algorithm
N - the type of node used in the spatial index structure
E - the type of entry used in the spatial node
All Implemented Interfaces:
Algorithm, InspectionUtilFrequentlyScanned, Parameterizable

@Title(value="K-Nearest Neighbor Join")
@Description(value="Algorithm to find the k-nearest neighbors of each object in a spatial database")
public class KNNJoin<V extends NumberVector<V,?>,D extends Distance<D>,N extends SpatialNode<N,E>,E extends SpatialEntry>
extends AbstractDistanceBasedAlgorithm<V,D,DataStore<KNNList<D>>>

Joins in a given spatial database to each object its k-nearest neighbors. This algorithm only supports spatial databases based on a spatial index structure.


Nested Class Summary
static class KNNJoin.Parameterizer<V extends NumberVector<V,?>,D extends Distance<D>,N extends SpatialNode<N,E>,E extends SpatialEntry>
          Parameterization class.
 
Field Summary
(package private)  int k
          The k parameter
static OptionID K_ID
          Parameter that specifies the k-nearest neighbors to be assigned, must be an integer greater than 0.
private static Logging logger
          The logger for this class.
 
Fields inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm
DISTANCE_FUNCTION_ID
 
Constructor Summary
KNNJoin(DistanceFunction<? super V,D> distanceFunction, int k)
          Constructor.
 
Method Summary
 TypeInformation[] getInputTypeRestriction()
          Get the input type restriction used for negotiating the data query.
protected  Logging getLogger()
          Get the (STATIC) logger for this class.
private  D processDataPages(DistanceQuery<V,D> distQ, N pr, N ps, WritableDataStore<KNNHeap<D>> knnLists, D pr_knn_distance)
          Processes the two data pages pr and ps and determines the k-nearest neighbors of pr in ps.
 DataStore<KNNList<D>> run(Database database, Relation<V> relation)
          Joins in the given spatial database to each object its k-nearest neighbors.
 
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractDistanceBasedAlgorithm
getDistanceFunction
 
Methods inherited from class de.lmu.ifi.dbs.elki.algorithm.AbstractAlgorithm
makeParameterDistanceFunction, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Logging logger
The logger for this class.


K_ID

public static final OptionID K_ID
Parameter that specifies the k-nearest neighbors to be assigned, must be an integer greater than 0. Default value: 1.


k

int k
The k parameter

Constructor Detail

KNNJoin

public KNNJoin(DistanceFunction<? super V,D> distanceFunction,
               int k)
Constructor.

Parameters:
distanceFunction - Distance function
k - k parameter
Method Detail

run

public DataStore<KNNList<D>> run(Database database,
                                 Relation<V> relation)
                                              throws IllegalStateException
Joins in the given spatial database to each object its k-nearest neighbors.

Throws:
IllegalStateException - if not suitable SpatialIndexTree was found or the specified distance function is not an instance of SpatialPrimitiveDistanceFunction.

processDataPages

private D processDataPages(DistanceQuery<V,D> distQ,
                           N pr,
                           N ps,
                           WritableDataStore<KNNHeap<D>> knnLists,
                           D pr_knn_distance)
Processes the two data pages pr and ps and determines the k-nearest neighbors of pr in ps.

Parameters:
distQ - the distance to use
pr - the first data page
ps - the second data page
knnLists - the knn lists for each data object
pr_knn_distance - the current knn distance of data page pr
Returns:
the k-nearest neighbor distance of pr in ps

getInputTypeRestriction

public TypeInformation[] getInputTypeRestriction()
Description copied from class: AbstractAlgorithm
Get the input type restriction used for negotiating the data query.

Specified by:
getInputTypeRestriction in interface Algorithm
Specified by:
getInputTypeRestriction in class AbstractAlgorithm<DataStore<KNNList<D extends Distance<D>>>>
Returns:
Type restriction

getLogger

protected Logging getLogger()
Description copied from class: AbstractAlgorithm
Get the (STATIC) logger for this class.

Specified by:
getLogger in class AbstractAlgorithm<DataStore<KNNList<D extends Distance<D>>>>
Returns:
the static logger

Release 0.4.0 (2011-09-20_1324)