GClasses

GClasses::GNeighborFinderCacheWrapper Class Reference

This wraps a neighbor finding algorithm. It caches the queries for neighbors for the purpose of improving runtime performance. More...

#include <GNeighborFinder.h>

Inheritance diagram for GClasses::GNeighborFinderCacheWrapper:
GClasses::GNeighborFinder

List of all members.

Public Member Functions

 GNeighborFinderCacheWrapper (GNeighborFinder *pNF, bool own)
 If own is true, then this will take ownership of pNF.
virtual ~GNeighborFinderCacheWrapper ()
virtual void neighbors (size_t *pOutNeighbors, size_t index)
 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.
virtual void neighbors (size_t *pOutNeighbors, double *pOutDistances, size_t index)
 pOutNeighbors and pOutDistances should both be arrays of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. 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.
virtual bool isCached ()
 See the comment for GNeighborFinder::isCached.
GNeighborFinderwrappedNeighborFinder ()
 Returns a pointer to the neighbor finder that this wraps.
size_t * cache ()
 Returns the cache of neighbors. (You should probably call fillCache before calling this.)
double * squaredDistanceTable ()
 Returns the table of squared dissimilarities.
void fillCache ()
 Ensures that the cache is populated with data for every index in the dataset.
size_t cutShortcuts (size_t cycleLen)
 Uses CycleCut to remove shortcut connections. (Assumes fillCache has already been called.)
void patchMissingSpots (GRand *pRand)
 Patches any missing neighbors by randomly selecting another of its neighbors to fill both spots.
void fillDistances (GDistanceMetric *pMetric)
 (Re)computes all neighbor distances using the specified metric.
void normalizeDistances ()
 Normalizes all the neighborhoods so that all neighbor distances are approximately 1.
bool isConnected ()
 Returns true iff the neighbors form a connected graph when each neighbor is evaluated as a bi-directional edge. (Assumes that fillCache has already been called.)

Protected Attributes

GNeighborFinderm_pNF
bool m_own
size_t * m_pCache
double * m_pDissims

Detailed Description

This wraps a neighbor finding algorithm. It caches the queries for neighbors for the purpose of improving runtime performance.


Constructor & Destructor Documentation

GClasses::GNeighborFinderCacheWrapper::GNeighborFinderCacheWrapper ( GNeighborFinder pNF,
bool  own 
)

If own is true, then this will take ownership of pNF.

virtual GClasses::GNeighborFinderCacheWrapper::~GNeighborFinderCacheWrapper ( ) [virtual]

Member Function Documentation

size_t* GClasses::GNeighborFinderCacheWrapper::cache ( ) [inline]

Returns the cache of neighbors. (You should probably call fillCache before calling this.)

size_t GClasses::GNeighborFinderCacheWrapper::cutShortcuts ( size_t  cycleLen)

Uses CycleCut to remove shortcut connections. (Assumes fillCache has already been called.)

void GClasses::GNeighborFinderCacheWrapper::fillCache ( )

Ensures that the cache is populated with data for every index in the dataset.

void GClasses::GNeighborFinderCacheWrapper::fillDistances ( GDistanceMetric pMetric)

(Re)computes all neighbor distances using the specified metric.

virtual bool GClasses::GNeighborFinderCacheWrapper::isCached ( ) [inline, virtual]

See the comment for GNeighborFinder::isCached.

Reimplemented from GClasses::GNeighborFinder.

bool GClasses::GNeighborFinderCacheWrapper::isConnected ( )

Returns true iff the neighbors form a connected graph when each neighbor is evaluated as a bi-directional edge. (Assumes that fillCache has already been called.)

virtual void GClasses::GNeighborFinderCacheWrapper::neighbors ( size_t *  pOutNeighbors,
double *  pOutDistances,
size_t  index 
) [virtual]

pOutNeighbors and pOutDistances should both be arrays of size neighborCount. index refers to the point/vector whose neighbors you want to obtain. The neighbors are not necessarily sorted, but you can call GNeighborFinder::sortNeighbors if you want them to be sorted. 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.

Implements GClasses::GNeighborFinder.

virtual void GClasses::GNeighborFinderCacheWrapper::neighbors ( size_t *  pOutNeighbors,
size_t  index 
) [virtual]

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.

Implements GClasses::GNeighborFinder.

void GClasses::GNeighborFinderCacheWrapper::normalizeDistances ( )

Normalizes all the neighborhoods so that all neighbor distances are approximately 1.

void GClasses::GNeighborFinderCacheWrapper::patchMissingSpots ( GRand pRand)

Patches any missing neighbors by randomly selecting another of its neighbors to fill both spots.

double* GClasses::GNeighborFinderCacheWrapper::squaredDistanceTable ( ) [inline]

Returns the table of squared dissimilarities.

GNeighborFinder* GClasses::GNeighborFinderCacheWrapper::wrappedNeighborFinder ( ) [inline]

Returns a pointer to the neighbor finder that this wraps.


Member Data Documentation