[mlpack-svn] r12614 - mlpack/trunk/src/mlpack/core/tree
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu May 3 20:09:22 EDT 2012
Author: rcurtin
Date: 2012-05-03 20:09:22 -0400 (Thu, 03 May 2012)
New Revision: 12614
Modified:
mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
Log:
Modify the API of BinarySpaceTree to include a few more methods. Starting to
settle on a more standard tree API.
Modified: mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp
===================================================================
--- mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-05-04 00:02:21 UTC (rev 12613)
+++ mlpack/trunk/src/mlpack/core/tree/binary_space_tree.hpp 2012-05-04 00:09:22 UTC (rev 12614)
@@ -10,6 +10,8 @@
#include "statistic.hpp"
+#include "traversers/single_tree_depth_first_traverser.hpp"
+
namespace mlpack {
namespace tree /** Trees and tree-building procedures. */ {
@@ -60,6 +62,18 @@
//! So other classes can use TreeType::Mat.
typedef MatType Mat;
+ //! Our preferred traverser. We are using a struct here so that we don't need
+ //! to specify the template parameters.
+ template<typename RuleType>
+ struct PreferredTraverser
+ {
+ //! We use a depth-first search by default.
+ typedef SingleTreeDepthFirstTraverser<
+ BinarySpaceTree<BoundType, StatisticType, MatType>,
+ RuleType
+ > Type;
+ };
+
/**
* Construct this as the root node of a binary space tree using the given
* dataset. This will modify the ordering of the points in the dataset!
@@ -257,6 +271,30 @@
*/
size_t Point(const size_t index) const;
+ //! Return the minimum distance to another node.
+ double MinDistance(const BinarySpaceTree* other) const
+ {
+ return bound.MinDistance(other->Bound());
+ }
+
+ //! Return the maximum distance to another node.
+ double MaxDistance(const BinarySpaceTree* other) const
+ {
+ return bound.MaxDistance(other->Bound());
+ }
+
+ //! Return the minimum distance to another point.
+ double MinDistance(const arma::vec& point) const
+ {
+ return bound.MinDistance(point);
+ }
+
+ //! Return the maximum distance to another point.
+ double MaxDistance(const arma::vec& point) const
+ {
+ return bound.MaxDistance(point);
+ }
+
/**
* Returns the dimension this parent's children are split on.
*/
@@ -288,6 +326,9 @@
*/
size_t Count() const;
+ //! Returns false: this tree type does not have self children.
+ static bool HasSelfChildren() { return false; }
+
private:
/**
* Private copy constructor, available only to fill (pad) the tree to a
More information about the mlpack-svn
mailing list