mlpack  2.0.1
single_tree_traverser.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_HPP
17 #define __MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_HPP
18 
19 #include <mlpack/core.hpp>
20 
21 #include "rectangle_tree.hpp"
22 
23 namespace mlpack {
24 namespace tree {
25 
26 template<typename MetricType,
27  typename StatisticType,
28  typename MatType,
29  typename SplitType,
30  typename DescentType>
31 template<typename RuleType>
32 class RectangleTree<MetricType, StatisticType, MatType, SplitType,
33  DescentType>::SingleTreeTraverser
34 {
35  public:
39  SingleTreeTraverser(RuleType& rule);
40 
48  void Traverse(const size_t queryIndex, const RectangleTree& referenceNode);
49 
51  size_t NumPrunes() const { return numPrunes; }
53  size_t& NumPrunes() { return numPrunes; }
54 
55  private:
56 
57  // We use this class and this function to make the sorting and scoring easy
58  // and efficient:
59  struct NodeAndScore
60  {
62  double score;
63  };
64 
65  static bool NodeComparator(const NodeAndScore& obj1, const NodeAndScore& obj2)
66  {
67  return obj1.score < obj2.score;
68  }
69 
71  RuleType& rule;
72 
74  size_t numPrunes;
75 };
76 
77 } // namespace tree
78 } // namespace mlpack
79 
80 // Include implementation.
81 #include "single_tree_traverser_impl.hpp"
82 
83 #endif
size_t numPrunes
The number of nodes which have been prenud during traversal.
Linear algebra utility functions, generally performed on matrices or vectors.
RectangleTree()
A default constructor.
size_t NumPrunes() const
Get the number of prunes.
static bool NodeComparator(const NodeAndScore &obj1, const NodeAndScore &obj2)
RuleType & rule
Reference to the rules with which the tree will be traversed.
size_t & NumPrunes()
Modify the number of prunes.
A rectangle type tree tree, such as an R-tree or X-tree.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...