Super class of binary space-partitioning trees. More...
#include <shark/Models/Trees/BinaryTree.h>
Public Member Functions | |
BinaryTree (std::size_t size) | |
Root node constructor: build the tree from data. | |
virtual | ~BinaryTree () |
Destroy the tree and its internal data structures. | |
BinaryTree * | parent () |
parent node | |
const BinaryTree * | parent () const |
parent node | |
bool | hasChildren () const |
bool | isLeaf () const |
BinaryTree * | left () |
"left" sub-node of the binary tree | |
const BinaryTree * | left () const |
"left" sub-node of the binary tree | |
BinaryTree * | right () |
"right" sub-node of the binary tree | |
const BinaryTree * | right () const |
"right" sub-node of the binary tree | |
std::size_t | size () const |
number of points inside the space represented by this node | |
std::size_t | nodes () const |
number of sub-nodes in this tree (including the node itself) | |
std::size_t | index (std::size_t point) const |
double | distanceFromPlane (value_type const &point) const |
Function describing the separation of space. | |
double | threshold () const |
Separation threshold. | |
bool | isLeft (value_type const &point) const |
bool | isRight (value_type const &point) const |
virtual AbstractKernelFunction< value_type > const * | kernel () const |
If the tree uses a kernel metric, returns a pointer to the kernel object, else NULL. | |
virtual double | squaredDistanceLowerBound (value_type const &point) const =0 |
Compute lower bound on the squared distance to the space cell. | |
Protected Member Functions | |
BinaryTree (BinaryTree *parent, std::size_t *list, std::size_t size) | |
Sub-node constructor. | |
virtual double | funct (value_type const &point) const =0 |
Function describing the separation of space. | |
template<class Range1 , class Range2 > | |
Range2::iterator | splitList (Range1 &values, Range2 &points) |
Split the data in the point list and calculate the treshold accordingly. | |
Protected Attributes | |
BinaryTree * | mep_parent |
parent node | |
BinaryTree * | mp_left |
"left" child node | |
BinaryTree * | mp_right |
"right" child node | |
std::size_t * | mp_indexList |
list of indices to points in the dataset | |
std::size_t | m_size |
number of points in this node | |
std::size_t | m_nodes |
number of nodes in the sub-tree represented by this node | |
double | m_threshold |
threshold for the separating function | |
Super class of binary space-partitioning trees.
Definition at line 137 of file BinaryTree.h.
|
inline |
Root node constructor: build the tree from data.
Please refer the specific sub-classes such as KDTree for examples of how the binary tree is built.
Definition at line 147 of file BinaryTree.h.
References shark::BinaryTree< InputT >::m_size, shark::BinaryTree< InputT >::mp_indexList, and SHARK_ASSERT.
|
inlinevirtual |
Destroy the tree and its internal data structures.
Definition at line 164 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mep_parent, shark::BinaryTree< InputT >::mp_indexList, shark::BinaryTree< InputT >::mp_left, and shark::BinaryTree< InputT >::mp_right.
|
inlineprotected |
|
inline |
Function describing the separation of space.
Definition at line 233 of file BinaryTree.h.
References shark::BinaryTree< InputT >::funct(), and shark::BinaryTree< InputT >::m_threshold.
Referenced by shark::LCTree< VectorType, CuttingAccuracy >::squaredDistanceLowerBound().
|
protectedpure virtual |
Function describing the separation of space.
Implemented in shark::KDTree< InputT >.
Referenced by shark::BinaryTree< InputT >::distanceFromPlane(), shark::BinaryTree< InputT >::isLeft(), and shark::BinaryTree< InputT >::isRight().
|
inline |
Does this node have children? Opposite of isLeaf()
Definition at line 183 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_left.
Referenced by shark::HierarchicalClustering< InputT >::hardMembership(), and shark::IterativeNNQuery< DataContainer >::IterativeNNQuery().
|
inline |
Definition at line 213 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_indexList.
|
inline |
Is this a leaf node? Opposite of hasChildren()
Definition at line 188 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_left.
|
inline |
return true if the reference point belongs to the "left" sub-node, or to the "negative" sub-cell.
Definition at line 244 of file BinaryTree.h.
References shark::BinaryTree< InputT >::funct(), and shark::BinaryTree< InputT >::m_threshold.
Referenced by shark::HierarchicalClustering< InputT >::hardMembership(), and shark::IterativeNNQuery< DataContainer >::IterativeNNQuery().
|
inline |
return true if the reference point belongs to the "right" sub-node, or to the "positive" sub-cell.
Definition at line 249 of file BinaryTree.h.
References shark::BinaryTree< InputT >::funct(), and shark::BinaryTree< InputT >::m_threshold.
|
inlinevirtual |
If the tree uses a kernel metric, returns a pointer to the kernel object, else NULL.
Definition at line 253 of file BinaryTree.h.
|
inline |
"left" sub-node of the binary tree
Definition at line 192 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_left.
Referenced by shark::KDTree< InputT >::buildTree(), shark::LCTree< VectorType, CuttingAccuracy >::buildTree(), shark::HierarchicalClustering< InputT >::hardMembership(), and shark::IterativeNNQuery< DataContainer >::IterativeNNQuery().
|
inline |
"left" sub-node of the binary tree
Definition at line 195 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_left.
|
inline |
number of sub-nodes in this tree (including the node itself)
Definition at line 210 of file BinaryTree.h.
References shark::BinaryTree< InputT >::m_nodes.
Referenced by shark::KDTree< InputT >::buildTree(), shark::KHCTree< Container, CuttingAccuracy >::buildTree(), shark::LCTree< VectorType, CuttingAccuracy >::buildTree(), shark::HierarchicalClustering< InputT >::hardMembership(), main(), and shark::HierarchicalClustering< InputT >::numberOfClusters().
|
inline |
parent node
Definition at line 175 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mep_parent.
Referenced by shark::KDTree< InputT >::lower(), and shark::KDTree< InputT >::upper().
|
inline |
parent node
Definition at line 178 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mep_parent.
|
inline |
"right" sub-node of the binary tree
Definition at line 199 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_right.
Referenced by shark::KDTree< InputT >::buildTree(), shark::LCTree< VectorType, CuttingAccuracy >::buildTree(), shark::HierarchicalClustering< InputT >::hardMembership(), and shark::IterativeNNQuery< DataContainer >::IterativeNNQuery().
|
inline |
"right" sub-node of the binary tree
Definition at line 202 of file BinaryTree.h.
References shark::BinaryTree< InputT >::mp_right.
|
inline |
number of points inside the space represented by this node
Definition at line 206 of file BinaryTree.h.
References shark::BinaryTree< InputT >::m_size.
|
inlineprotected |
Split the data in the point list and calculate the treshold accordingly.
The method computes the optimal threshold given the distance of every element of the set and partitions the point range accordingly
values | the value of every point returned by funct(point) |
points | the points themselves |
Definition at line 315 of file BinaryTree.h.
References shark::BinaryTree< InputT >::m_threshold, and shark::partitionEqually().
Referenced by shark::KDTree< InputT >::buildTree(), and shark::LCTree< VectorType, CuttingAccuracy >::buildTree().
|
pure virtual |
Compute lower bound on the squared distance to the space cell.
Implemented in shark::KDTree< InputT >.
|
inline |
Separation threshold.
Definition at line 238 of file BinaryTree.h.
References shark::BinaryTree< InputT >::m_threshold.
Referenced by shark::KDTree< InputT >::lower(), and shark::KDTree< InputT >::upper().
|
protected |
number of nodes in the sub-tree represented by this node
Definition at line 361 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::nodes().
|
protected |
number of points in this node
Definition at line 358 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::BinaryTree(), and shark::BinaryTree< InputT >::size().
|
protected |
threshold for the separating function
Definition at line 364 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::distanceFromPlane(), shark::BinaryTree< InputT >::isLeft(), shark::BinaryTree< InputT >::isRight(), shark::BinaryTree< InputT >::splitList(), and shark::BinaryTree< InputT >::threshold().
|
protected |
parent node
Definition at line 346 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::parent(), shark::BinaryTree< InputT >::parent(), and shark::BinaryTree< InputT >::~BinaryTree().
|
protected |
list of indices to points in the dataset
Definition at line 355 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::BinaryTree(), shark::BinaryTree< InputT >::index(), and shark::BinaryTree< InputT >::~BinaryTree().
|
protected |
"left" child node
Definition at line 349 of file BinaryTree.h.
Referenced by shark::BinaryTree< InputT >::hasChildren(), shark::BinaryTree< InputT >::isLeaf(), shark::BinaryTree< InputT >::left(), shark::BinaryTree< InputT >::left(), shark::KDTree< InputT >::upper(), and shark::BinaryTree< InputT >::~BinaryTree().
|
protected |
"right" child node
Definition at line 352 of file BinaryTree.h.
Referenced by shark::KDTree< InputT >::lower(), shark::BinaryTree< InputT >::right(), shark::BinaryTree< InputT >::right(), and shark::BinaryTree< InputT >::~BinaryTree().