GClasses
GClasses::GNeighborFinder Class Referenceabstract

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

#include <GNeighborFinder.h>

Inheritance diagram for GClasses::GNeighborFinder:
GClasses::GNeighborFinderGeneralizing GClasses::GNeighborGraph GClasses::GSaffron GClasses::GSequenceNeighborFinder GClasses::GTemporalNeighborFinder GClasses::GBallTree GClasses::GBruteForceNeighborFinder GClasses::GKdTree

Public Member Functions

 GNeighborFinder (const GMatrix *pData, size_t neighborCount)
 
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 bool isCached ()
 Returns true iff the neighbors and distances are pre-computed. More...
 
size_t neighborCount ()
 Returns the number of neighbors to find. More...
 
virtual void neighbors (size_t *pOutNeighbors, size_t index)=0
 Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors should be an array of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. The value INVALID_INDEX may be used to fill slots with no point if necessary. More...
 
virtual void neighbors (size_t *pOutNeighbors, double *pOutDistances, size_t index)=0
 Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors and pOutDistances should both be arrays of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. If there are not enough points in the data set to fill the neighbor array, the empty ones will have an index of INVALID_INDEX. More...
 
void sortNeighbors (size_t *pNeighbors, double *pDistances)
 Uses Quick Sort to sort the neighbors from least to most dissimilar, followed by any slots for with INVALID_INDEX for the index. (Note: This method is pointless, since the neighors are already guaranteed to come in sorted order. Todo: figure out why it is still here) More...
 

Static Public Member Functions

static void sortNeighbors (size_t neighborCount, size_t *pNeighbors, double *pDistances)
 Uses Quick Sort to sort the neighbors from least to most dissimilar, followed by any slots for with INVALID_INDEX for the index. (Note: This method is pointless, since the neighors are already guaranteed to come in sorted order. Todo: figure out why it is still here) More...
 

Protected Attributes

size_t m_neighborCount
 
const GMatrixm_pData
 

Detailed Description

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

Constructor & Destructor Documentation

GClasses::GNeighborFinder::GNeighborFinder ( const GMatrix pData,
size_t  neighborCount 
)
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 bool GClasses::GNeighborFinder::isCached ( )
inlinevirtual

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

Reimplemented in GClasses::GNeighborGraph.

size_t GClasses::GNeighborFinder::neighborCount ( )
inline

Returns the number of neighbors to find.

virtual void GClasses::GNeighborFinder::neighbors ( size_t *  pOutNeighbors,
size_t  index 
)
pure virtual

Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors should be an array of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. The value INVALID_INDEX may be used to fill slots with no point if necessary.

Implemented in GClasses::GSequenceNeighborFinder, GClasses::GTemporalNeighborFinder, GClasses::GSaffron, GClasses::GBallTree, GClasses::GKdTree, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.

virtual void GClasses::GNeighborFinder::neighbors ( size_t *  pOutNeighbors,
double *  pOutDistances,
size_t  index 
)
pure virtual

Returns the k-nearest neighbors of the point specified by index. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. pOutNeighbors and pOutDistances should both be arrays of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. If there are not enough points in the data set to fill the neighbor array, the empty ones will have an index of INVALID_INDEX.

Implemented in GClasses::GSequenceNeighborFinder, GClasses::GTemporalNeighborFinder, GClasses::GSaffron, GClasses::GBallTree, GClasses::GKdTree, GClasses::GBruteForceNeighborFinder, and GClasses::GNeighborGraph.

static void GClasses::GNeighborFinder::sortNeighbors ( size_t  neighborCount,
size_t *  pNeighbors,
double *  pDistances 
)
static

Uses Quick Sort to sort the neighbors from least to most dissimilar, followed by any slots for with INVALID_INDEX for the index. (Note: This method is pointless, since the neighors are already guaranteed to come in sorted order. Todo: figure out why it is still here)

void GClasses::GNeighborFinder::sortNeighbors ( size_t *  pNeighbors,
double *  pDistances 
)

Uses Quick Sort to sort the neighbors from least to most dissimilar, followed by any slots for with INVALID_INDEX for the index. (Note: This method is pointless, since the neighors are already guaranteed to come in sorted order. Todo: figure out why it is still here)

Member Data Documentation

size_t GClasses::GNeighborFinder::m_neighborCount
protected
const GMatrix* GClasses::GNeighborFinder::m_pData
protected