Class VPTree<O>
- java.lang.Object
-
- elki.index.tree.metrical.vptree.VPTree<O>
-
- Type Parameters:
O- Object type
- All Implemented Interfaces:
DistancePriorityIndex<O>,Index,KNNIndex<O>,RangeIndex<O>
@Reference(authors="P. N. Yianilos", title="Data Structures and Algorithms for Nearest Neighbor Search in General Metric Spaces", booktitle="Proc. ACM/SIGACT-SIAM Symposium on Discrete Algorithms", url="http://dl.acm.org/citation.cfm?id=313559.313789", bibkey="DBLP:conf/soda/Yianilos93") public class VPTree<O> extends java.lang.Object implements DistancePriorityIndex<O>
Vantage Point Tree with no additional informationIn a Vantage Point Tree the data is split at the median distance to a vantage point at every node.
The distance function in the original paper was bounded to have a limited tau size. In this class the function is not bounded, as we can just limit tau to Double.MAX_VALUE
Reference:
P. N. Yianilos
Data Structures and Algorithms for Nearest Neighbor Search in General Metric Spaces
Proc. ACM/SIGACT-SIAM Symposium on Discrete Algorithms- Since:
- 0.8.0
- Author:
- Robert Gehde, Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classVPTree.BuilderBuild the VP-Treestatic classVPTree.Factory<O extends NumberVector>Index factory for the VP-Treeprotected static classVPTree.NodeThe Node Class saves the important information for the each NodeclassVPTree.VPTreeKNNDBIDSearcherkNN search for the VP-Tree.classVPTree.VPTreeKNNObjectSearcherkNN search for the VP-Tree.static classVPTree.VPTreeKNNSearcherkNN search for the VP-Tree.classVPTree.VPTreePriorityDBIDSearcherRange search for the VP-tree.classVPTree.VPTreePriorityObjectSearcherRange search for the VP-tree.classVPTree.VPTreePrioritySearcher<Q>Priority search for the VP-Tree.classVPTree.VPTreeRangeDBIDSearcherRange search for the VP-tree.classVPTree.VPTreeRangeObjectSearcherRange search for the VP-tree.static classVPTree.VPTreeRangeSearcherRange search for the VP-tree.
-
Field Summary
Fields Modifier and Type Field Description (package private) longdistComputationsCounter for distance computations.(package private) Distance<? super O>distFuncDistance Function to useprivate DistanceQuery<O>distQueryActual distance query on the Dataprivate static LoggingLOGClass logger.(package private) RandomFactoryrandomRandom factory for selecting vantage pointsprotected Relation<O>relationThe representation we are bound to.(package private) VPTree.NoderootRoot node from the tree(package private) intsampleSizeSample size for selecting vantage points(package private) inttruncateTruncation parameter
-
Constructor Summary
Constructors Constructor Description VPTree(Relation<O> relation, Distance<? super O> distance, int leafsize)Constructor with default values, used by EmpiricalQueryOptimizerVPTree(Relation<O> relation, Distance<? super O> distance, RandomFactory random, int sampleSize, int truncate)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private doubledistance(DBIDRef a, DBIDRef b)Compute a distance, and count.private doubledistance(O a, DBIDRef b)Compute a distance, and count.voidinitialize()Initialize the index.KNNSearcher<DBIDRef>kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.KNNSearcher<O>kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)Get a KNN query object for the given distance query and k.voidlogStatistics()Send statistics to the logger, if enabled.PrioritySearcher<DBIDRef>priorityByDBID(DistanceQuery<O> distanceQuery, double maxrange, int flags)Get a priority search object.PrioritySearcher<O>priorityByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)Get a priority search object.RangeSearcher<DBIDRef>rangeByDBID(DistanceQuery<O> distanceQuery, double maxrange, int flags)Get a range query object for the given distance query and k.RangeSearcher<O>rangeByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)Get a range query object for the given distance query and k.
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Class logger.
-
distQuery
private DistanceQuery<O> distQuery
Actual distance query on the Data
-
random
RandomFactory random
Random factory for selecting vantage points
-
sampleSize
int sampleSize
Sample size for selecting vantage points
-
truncate
int truncate
Truncation parameter
-
distComputations
long distComputations
Counter for distance computations.
-
root
VPTree.Node root
Root node from the tree
-
-
Constructor Detail
-
VPTree
public VPTree(Relation<O> relation, Distance<? super O> distance, int leafsize)
Constructor with default values, used by EmpiricalQueryOptimizer- Parameters:
relation- data for tree constructiondistance- distance function for tree constructionleafsize- Leaf size and sample size (simpler parameterization)
-
VPTree
public VPTree(Relation<O> relation, Distance<? super O> distance, RandomFactory random, int sampleSize, int truncate)
Constructor.- Parameters:
relation- data for tree constructiondistance- distance function for tree constructionrandom- Random generator for samplingsampleSize- Sample size for finding the vantage pointtruncate- Leaf size threshold
-
-
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
-
distance
private double distance(DBIDRef a, DBIDRef b)
Compute a distance, and count.- Parameters:
a- First objectb- Second object- Returns:
- Distance
-
distance
private double distance(O a, DBIDRef b)
Compute a distance, and count.- Parameters:
a- First objectb- Second object- Returns:
- Distance
-
kNNByObject
public KNNSearcher<O> kNNByObject(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
kNNByObjectin interfaceDistancePriorityIndex<O>- Specified by:
kNNByObjectin interfaceKNNIndex<O>- Parameters:
distanceQuery- Distance querymaxk- Maximum value of kflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
kNNByDBID
public KNNSearcher<DBIDRef> kNNByDBID(DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:KNNIndexGet a KNN query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
-
rangeByObject
public RangeSearcher<O> rangeByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:RangeIndexGet a range query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
rangeByObjectin interfaceDistancePriorityIndex<O>- Specified by:
rangeByObjectin interfaceRangeIndex<O>- Parameters:
distanceQuery- Distance querymaxrange- Maximum rangeflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
rangeByDBID
public RangeSearcher<DBIDRef> rangeByDBID(DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:RangeIndexGet a range query object for the given distance query and k.This function MAY return null, when the given distance is not supported!
- Specified by:
rangeByDBIDin interfaceRangeIndex<O>- Parameters:
distanceQuery- Distance querymaxrange- Maximum rangeflags- Hints for the optimizer- Returns:
- KNN Query object or
null
-
priorityByObject
public PrioritySearcher<O> priorityByObject(DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:DistancePriorityIndexGet a priority search object.- Specified by:
priorityByObjectin interfaceDistancePriorityIndex<O>- Parameters:
distanceQuery- Distance querymaxrange- Maximum search range (may beDouble.POSITIVE_INFINITYflags- Optimizer hints- Returns:
- Priority searcher
-
priorityByDBID
public PrioritySearcher<DBIDRef> priorityByDBID(DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:DistancePriorityIndexGet a priority search object.- Specified by:
priorityByDBIDin interfaceDistancePriorityIndex<O>- Parameters:
distanceQuery- Distance querymaxrange- Maximum search range (may beDouble.POSITIVE_INFINITYflags- Optimizer hints- Returns:
- Priority searcher
-
logStatistics
public void logStatistics()
Description copied from interface:IndexSend statistics to the logger, if enabled.Note: you must have set the logging level appropriately before initializing the index! Otherwise, the index might not have collected the desired statistics.
- Specified by:
logStatisticsin interfaceIndex
-
-