|
GClasses
|
This wraps a neighbor finding algorithm. It caches the queries for neighbors for the purpose of improving runtime performance.
#include <GNeighborFinder.h>
Public Member Functions | |
| GNeighborGraph (GNeighborFinder *pNF, bool own, size_t neighbors) | |
| Makes a GNeighborGraph that has precomputed the k-nearest neighbors of each point in a dataset. If own is true, then this will take ownership of pNF. More... | |
| GNeighborGraph (double squaredRadius, GNeighborFinder *pNF, bool own) | |
| Makes a GNeighborGraph that has precomputed the neighbors of each point in a dataset within a specified radius. More... | |
| GNeighborGraph (bool own, GNeighborFinderGeneralizing *pNF) | |
| Makes a GNeighborGraph assuming the data represents a sequence of observations. First, it computes the distance between each point and its previous and next points. Then, it finds all neighbors within a radius of the maximum of those two distances. More... | |
| virtual | ~GNeighborGraph () |
| size_t | cutShortcuts (size_t cycleLen) |
| Uses CycleCut to remove shortcut connections. (Assumes fillCache has already been called.) More... | |
| virtual double | distance (size_t i) |
| See the comment for GNeighborFinder::distance. More... | |
| void | dropInvalidNeighbors () |
| Drops all neighbors that have been set to INVALID_INDEX. This method is used by CycleCut. It is probably not useful for any other purpose. More... | |
| virtual size_t | findNearest (size_t k, size_t pointIndex) |
| See the comment for GNeighborFinder::findNearest. More... | |
| virtual size_t | findWithinRadius (double squaredRadius, size_t pointIndex) |
| See the comment for GNeighborFinder::findWithinRadius. More... | |
| virtual bool | isCached () |
| See the comment for GNeighborFinder::isCached. More... | |
| 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.) More... | |
| virtual size_t | neighbor (size_t i) |
| See the comment for GNeighborFinder::neighbor. More... | |
| void | recomputeDistances (GDistanceMetric *pMetric) |
| recomputes all neighbor distances using the specified metric. More... | |
| void | set (size_t point, size_t neighbor_number, size_t neighbor) |
| Sets the specified neighbor. (Does not change the distance.) This method is used by CycleCut. It is probably not useful for any other purpose. More... | |
| void | swapInData (const GMatrix *pNewData) |
| Uses pNewData for subsequent calls to recomputeDistances. More... | |
| GNeighborFinder * | wrappedNeighborFinder () |
| Returns a pointer to the neighbor finder that this wraps. More... | |
Public Member Functions inherited from GClasses::GNeighborFinder | |
| 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 GMatrix * | data () |
| Returns the data passed to the constructor of this object. More... | |
Protected Member Functions | |
| void | fillCacheNearest (size_t k) |
| Fills the cache with the k-nearest neighbors of each point. More... | |
| void | fillCacheRadius (double squaredRadius) |
| Fills the cache with the neighbors of each point within a specified radius. More... | |
Protected Attributes | |
| std::vector< std::vector< double > > | m_dists |
| size_t | m_focus |
| std::vector< std::vector< size_t > > | m_neighs |
| bool | m_own |
| GNeighborFinder * | m_pNF |
Protected Attributes inherited from GClasses::GNeighborFinder | |
| const GMatrix * | m_pData |
| GClasses::GNeighborGraph::GNeighborGraph | ( | GNeighborFinder * | pNF, |
| bool | own, | ||
| size_t | neighbors | ||
| ) |
Makes a GNeighborGraph that has precomputed the k-nearest neighbors of each point in a dataset. If own is true, then this will take ownership of pNF.
| GClasses::GNeighborGraph::GNeighborGraph | ( | double | squaredRadius, |
| GNeighborFinder * | pNF, | ||
| bool | own | ||
| ) |
Makes a GNeighborGraph that has precomputed the neighbors of each point in a dataset within a specified radius.
| GClasses::GNeighborGraph::GNeighborGraph | ( | bool | own, |
| GNeighborFinderGeneralizing * | pNF | ||
| ) |
Makes a GNeighborGraph assuming the data represents a sequence of observations. First, it computes the distance between each point and its previous and next points. Then, it finds all neighbors within a radius of the maximum of those two distances.
|
virtual |
| size_t GClasses::GNeighborGraph::cutShortcuts | ( | size_t | cycleLen | ) |
Uses CycleCut to remove shortcut connections. (Assumes fillCache has already been called.)
|
inlinevirtual |
See the comment for GNeighborFinder::distance.
Implements GClasses::GNeighborFinder.
| void GClasses::GNeighborGraph::dropInvalidNeighbors | ( | ) |
Drops all neighbors that have been set to INVALID_INDEX. This method is used by CycleCut. It is probably not useful for any other purpose.
|
protected |
Fills the cache with the k-nearest neighbors of each point.
|
protected |
Fills the cache with the neighbors of each point within a specified radius.
|
inlinevirtual |
See the comment for GNeighborFinder::findNearest.
Implements GClasses::GNeighborFinder.
|
inlinevirtual |
See the comment for GNeighborFinder::findWithinRadius.
Implements GClasses::GNeighborFinder.
|
inlinevirtual |
See the comment for GNeighborFinder::isCached.
Reimplemented from GClasses::GNeighborFinder.
| bool GClasses::GNeighborGraph::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.)
|
inlinevirtual |
See the comment for GNeighborFinder::neighbor.
Implements GClasses::GNeighborFinder.
| void GClasses::GNeighborGraph::recomputeDistances | ( | GDistanceMetric * | pMetric | ) |
recomputes all neighbor distances using the specified metric.
| void GClasses::GNeighborGraph::set | ( | size_t | point, |
| size_t | neighbor_number, | ||
| size_t | neighbor | ||
| ) |
Sets the specified neighbor. (Does not change the distance.) This method is used by CycleCut. It is probably not useful for any other purpose.
| void GClasses::GNeighborGraph::swapInData | ( | const GMatrix * | pNewData | ) |
Uses pNewData for subsequent calls to recomputeDistances.
|
inline |
Returns a pointer to the neighbor finder that this wraps.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |