![]() |
Ice Sheet System Model
4.18
Code documentation
|
#include <Covertree.h>
Data Structures | |
class | CoverTreeNode |
Public Member Functions | |
Covertree (int maxDist, const std::vector< Observation > &points=std::vector< Observation >()) | |
~Covertree () | |
void | insert (const Observation &newObservation) |
bool | isValidTree () const |
void | remove (const Observation &p) |
std::vector< Observation > | kNearestNeighbors (const Observation &p, const unsigned int &k) const |
int | get_numberofobs () |
CoverTreeNode * | getRoot () const |
void | print () const |
Data Fields | |
double | base |
Private Types | |
typedef std::pair< double, CoverTreeNode * > | distNodePair |
Private Member Functions | |
distNodePair | distance (const Observation &p, const std::vector< CoverTreeNode * > &Q) |
bool | insert_rec (const Observation &p, const std::vector< distNodePair > &Qi, const int &level) |
std::vector< CoverTreeNode * > | kNearestNodes (const Observation &o, const unsigned int &k) const |
void | remove_rec (const Observation &p, std::map< int, std::vector< distNodePair > > &coverSets, int level, bool &multi) |
Private Attributes | |
CoverTreeNode * | _root |
unsigned int | _numNodes |
int | _maxLevel |
int | _minLevel |
Definition at line 8 of file Covertree.h.
|
private |
Definition at line 45 of file Covertree.h.
Covertree::Covertree | ( | int | maxDist, |
const std::vector< Observation > & | points = std::vector<Observation>() |
||
) |
Constructs a cover tree which begins with all points in points.
maxDist should be the maximum distance that any two points can have between each other. IE p.distance(q) < maxDist for all p,q that you will ever try to insert. The cover tree may be invalid if an inaccurate maxDist is given.
Definition at line 6 of file Covertree.cpp.
Covertree::~Covertree | ( | ) |
Definition at line 17 of file Covertree.cpp.
|
private |
Definition at line 33 of file Covertree.cpp.
|
private |
Recursive implementation of the insert algorithm (see paper).
Definition at line 69 of file Covertree.cpp.
|
private |
Definition at line 108 of file Covertree.cpp.
|
private |
Definition at line 232 of file Covertree.cpp.
void Covertree::insert | ( | const Observation & | newObservation | ) |
Insert newPoint into the cover tree. If newPoint is already present, (that is, newPoint==p for some p already in the tree), then the tree is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then newPoint WILL be inserted and both points may be returned in k-nearest- neighbor searches.
Definition at line 49 of file Covertree.cpp.
bool Covertree::isValidTree | ( | ) | const |
Just for testing/debugging. Returns true iff the cover tree satisfies the the covering tree invariants (every node in level i is greater than base^i distance from every other node, and every node in level i is less than or equal to base^i distance from its children). See the cover tree papers for details.
Definition at line 376 of file Covertree.cpp.
void Covertree::remove | ( | const Observation & | p | ) |
Remove point p from the cover tree. If p is not present in the tree, it will remain unchanged. Otherwise, this will remove exactly one point q from the tree satisfying p==q.
Definition at line 194 of file Covertree.cpp.
std::vector< Observation > Covertree::kNearestNeighbors | ( | const Observation & | p, |
const unsigned int & | k | ||
) | const |
Returns the k nearest points to p in order (the 0th element of the vector is closest to p, 1th is next, etc). It may return greater than k points if there is a tie for the kth place.
Definition at line 155 of file Covertree.cpp.
int Covertree::get_numberofobs | ( | ) |
Definition at line 46 of file Covertree.cpp.
Covertree::CoverTreeNode * Covertree::getRoot | ( | ) | const |
Definition at line 367 of file Covertree.cpp.
void Covertree::print | ( | ) | const |
|
private |
Definition at line 47 of file Covertree.h.
|
private |
Definition at line 48 of file Covertree.h.
|
private |
Definition at line 49 of file Covertree.h.
|
private |
Definition at line 51 of file Covertree.h.
double Covertree::base |
Definition at line 65 of file Covertree.h.