breadth_first_dual_tree_traverser.hpp
Go to the documentation of this file.
1 
15 #ifndef MLPACK_CORE_TREE_BINARY_SPACE_TREE_BF_DUAL_TREE_TRAVERSER_HPP
16 #define MLPACK_CORE_TREE_BINARY_SPACE_TREE_BF_DUAL_TREE_TRAVERSER_HPP
17 
18 #include <mlpack/prereqs.hpp>
19 #include <queue>
20 
21 #include "../binary_space_tree.hpp"
22 
23 namespace mlpack {
24 namespace tree {
25 
26 template<typename TreeType, typename TraversalInfoType>
27 struct QueueFrame
28 {
29  TreeType* queryNode;
30  TreeType* referenceNode;
31  size_t queryDepth;
32  double score;
33  TraversalInfoType traversalInfo;
34 };
35 
36 template<typename MetricType,
37  typename StatisticType,
38  typename MatType,
39  template<typename BoundMetricType, typename...> class BoundType,
40  template<typename SplitBoundType, typename SplitMatType>
41  class SplitType>
42 template<typename RuleType>
43 class BinarySpaceTree<MetricType, StatisticType, MatType, BoundType,
44  SplitType>::BreadthFirstDualTreeTraverser
45 {
46  public:
50  BreadthFirstDualTreeTraverser(RuleType& rule);
51 
54 
61  void Traverse(BinarySpaceTree& queryNode,
63  void Traverse(BinarySpaceTree& queryNode,
64  std::priority_queue<QueueFrameType>& referenceQueue);
65 
67  size_t NumPrunes() const { return numPrunes; }
69  size_t& NumPrunes() { return numPrunes; }
70 
72  size_t NumVisited() const { return numVisited; }
74  size_t& NumVisited() { return numVisited; }
75 
77  size_t NumScores() const { return numScores; }
79  size_t& NumScores() { return numScores; }
80 
82  size_t NumBaseCases() const { return numBaseCases; }
84  size_t& NumBaseCases() { return numBaseCases; }
85 
86  private:
88  RuleType& rule;
89 
91  size_t numPrunes;
92 
94  size_t numVisited;
95 
97  size_t numScores;
98 
100  size_t numBaseCases;
101 
104  typename RuleType::TraversalInfoType traversalInfo;
105 };
106 
107 } // namespace tree
108 } // namespace mlpack
109 
110 // Include implementation.
111 #include "breadth_first_dual_tree_traverser_impl.hpp"
112 
113 #endif // MLPACK_CORE_TREE_BINARY_SPACE_TREE_BF_DUAL_TREE_TRAVERSER_HPP
QueueFrame< BinarySpaceTree, typename RuleType::TraversalInfoType > QueueFrameType
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
A binary space partitioning tree, such as a KD-tree or a ball tree.
size_t & NumScores()
Modify the number of times a node combination was scored.
size_t & NumVisited()
Modify the number of visited combinations.
size_t & NumBaseCases()
Modify the number of times a base case was calculated.
size_t NumScores() const
Get the number of times a node combination was scored.
size_t NumVisited() const
Get the number of visited combinations.
size_t NumBaseCases() const
Get the number of times a base case was calculated.