GClasses
GClasses::GNeighborFinder Class Referenceabstract

Detailed Description

Finds the k-nearest neighbors of any vector in a dataset.

#include <GNeighborFinder.h>

Inheritance diagram for GClasses::GNeighborFinder:
GClasses::GNeighborFinderGeneralizing GClasses::GNeighborGraph GClasses::GBallTree GClasses::GBruteForceNeighborFinder GClasses::GKdTree GClasses::GSparseNeighborFinder

Public Member Functions

 GNeighborFinder (const GMatrix *pData)
 
virtual ~GNeighborFinder ()
 
virtual bool canGeneralize ()
 Returns true if this neighbor finder can operate on points that are not in the dataset passed to the constructor. More...
 
const GMatrixdata ()
 Returns the data passed to the constructor of this object. More...
 
virtual double distance (size_t i)=0
 Returns the distance to the ith neighbor of the last point passed to "findNearest". (Behavior is undefined if findNearest has not yet been called.) More...
 
virtual size_t findNearest (size_t k, size_t pointIndex)=0
 Finds the k-nearest neighbors of the specified point index. Returns the number of neighbors found. Call "neighbor" or "distance" to obtain the neighbors and distances that were found. More...
 
virtual size_t findWithinRadius (double squaredRadius, size_t pointIndex)=0
 Finds all neighbors of the specified point index within a specified radius. Returns the number of neighbors found. Call "neighbor" or "distance" to obtain the neighbors and distances that were found. More...
 
virtual bool isCached ()
 Returns true iff the neighbors and distances are pre-computed. More...
 
virtual size_t neighbor (size_t i)=0
 Returns the point index of the ith neighbor of the last point passed to "findNearest". (Behavior is undefined if findNearest has not yet been called.) More...
 

Protected Attributes

const GMatrixm_pData
 

Constructor & Destructor Documentation

GClasses::GNeighborFinder::GNeighborFinder ( const GMatrix pData)
inline
virtual GClasses::GNeighborFinder::~GNeighborFinder ( )
inlinevirtual

Member Function Documentation

virtual bool GClasses::GNeighborFinder::canGeneralize ( )
inlinevirtual

Returns true if this neighbor finder can operate on points that are not in the dataset passed to the constructor.

Reimplemented in GClasses::GNeighborFinderGeneralizing.

const GMatrix* GClasses::GNeighborFinder::data ( )
inline

Returns the data passed to the constructor of this object.

virtual double GClasses::GNeighborFinder::distance ( size_t  i)
pure virtual

Returns the distance to the ith neighbor of the last point passed to "findNearest". (Behavior is undefined if findNearest has not yet been called.)

Implemented in GClasses::GNeighborFinderGeneralizing, and GClasses::GNeighborGraph.

virtual size_t GClasses::GNeighborFinder::findNearest ( size_t  k,
size_t  pointIndex 
)
pure virtual

Finds the k-nearest neighbors of the specified point index. Returns the number of neighbors found. Call "neighbor" or "distance" to obtain the neighbors and distances that were found.

Implemented in GClasses::GBallTree, GClasses::GKdTree, GClasses::GSparseNeighborFinder, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.

virtual size_t GClasses::GNeighborFinder::findWithinRadius ( double  squaredRadius,
size_t  pointIndex 
)
pure virtual

Finds all neighbors of the specified point index within a specified radius. Returns the number of neighbors found. Call "neighbor" or "distance" to obtain the neighbors and distances that were found.

Implemented in GClasses::GBallTree, GClasses::GKdTree, GClasses::GSparseNeighborFinder, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.

virtual bool GClasses::GNeighborFinder::isCached ( )
inlinevirtual

Returns true iff the neighbors and distances are pre-computed.

Reimplemented in GClasses::GNeighborGraph.

virtual size_t GClasses::GNeighborFinder::neighbor ( size_t  i)
pure virtual

Returns the point index of the ith neighbor of the last point passed to "findNearest". (Behavior is undefined if findNearest has not yet been called.)

Implemented in GClasses::GNeighborFinderGeneralizing, and GClasses::GNeighborGraph.

Member Data Documentation

const GMatrix* GClasses::GNeighborFinder::m_pData
protected