mlpack  master
single_tree_traverser.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_HPP
15 #define MLPACK_CORE_TREE_RECTANGLE_TREE_SINGLE_TREE_TRAVERSER_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 #include "rectangle_tree.hpp"
20 
21 namespace mlpack {
22 namespace tree {
23 
24 template<typename MetricType,
25  typename StatisticType,
26  typename MatType,
27  typename SplitType,
28  typename DescentType,
29  template<typename> class AuxiliaryInformationType>
30 template<typename RuleType>
31 class RectangleTree<MetricType, StatisticType, MatType, SplitType,
32  DescentType, AuxiliaryInformationType>::SingleTreeTraverser
33 {
34  public:
38  SingleTreeTraverser(RuleType& rule);
39 
47  void Traverse(const size_t queryIndex, const RectangleTree& referenceNode);
48 
50  size_t NumPrunes() const { return numPrunes; }
52  size_t& NumPrunes() { return numPrunes; }
53 
54  private:
55 
56  // We use this class and this function to make the sorting and scoring easy
57  // and efficient:
58  struct NodeAndScore
59  {
61  double score;
62  };
63 
64  static bool NodeComparator(const NodeAndScore& obj1, const NodeAndScore& obj2)
65  {
66  return obj1.score < obj2.score;
67  }
68 
70  RuleType& rule;
71 
73  size_t numPrunes;
74 };
75 
76 } // namespace tree
77 } // namespace mlpack
78 
79 // Include implementation.
80 #include "single_tree_traverser_impl.hpp"
81 
82 #endif
size_t numPrunes
The number of nodes which have been prenud during traversal.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
The core includes that mlpack expects; standard C++ includes and Armadillo.
RuleType & rule
Reference to the rules with which the tree will be traversed.
A rectangle type tree tree, such as an R-tree or X-tree.
RectangleTree()
A default constructor.
size_t & NumPrunes()
Modify the number of prunes.
static bool NodeComparator(const NodeAndScore &obj1, const NodeAndScore &obj2)
size_t NumPrunes() const
Get the number of prunes.