[mlpack-svn] r14399 - mlpack/trunk/src/mlpack/methods/emst
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Feb 26 17:50:34 EST 2013
Author: rcurtin
Date: 2013-02-26 17:50:34 -0500 (Tue, 26 Feb 2013)
New Revision: 14399
Modified:
mlpack/trunk/src/mlpack/methods/emst/dtb.hpp
mlpack/trunk/src/mlpack/methods/emst/dtb_impl.hpp
Log:
Adapt to modified statistic API.
Modified: mlpack/trunk/src/mlpack/methods/emst/dtb.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/emst/dtb.hpp 2013-02-26 22:42:42 UTC (rev 14398)
+++ mlpack/trunk/src/mlpack/methods/emst/dtb.hpp 2013-02-26 22:50:34 UTC (rev 14399)
@@ -48,23 +48,21 @@
public:
/**
- * A generic initializer.
+ * A generic initializer. Sets the maximum neighbor distance to its default,
+ * and the component membership to -1 (no component).
*/
DTBStat();
/**
- * An initializer for leaves.
+ * This is called when a node is finished initializing. We set the maximum
+ * neighbor distance to its default, and if possible, we set the component
+ * membership of the node (if it has only one point and no children).
+ *
+ * @param node Node that has been finished.
*/
- template<typename MatType>
- DTBStat(const MatType& dataset, const size_t start, const size_t count);
+ template<typename TreeType>
+ DTBStat(const TreeType& node);
- /**
- * An initializer for non-leaves.
- */
- template<typename MatType>
- DTBStat(const MatType& dataset, const size_t start, const size_t count,
- const DTBStat& leftStat, const DTBStat& rightStat);
-
//! Get the maximum neighbor distance.
double MaxNeighborDistance() const { return maxNeighborDistance; }
//! Modify the maximum neighbor distance.
@@ -79,7 +77,7 @@
/**
* Performs the MST calculation using the Dual-Tree Boruvka algorithm, using any
- * type of tree.
+ * type of tree.
*
* For more information on the algorithm, see the following citation:
*
@@ -109,9 +107,9 @@
* More advanced usage of the class can use different types of trees, pass in an
* already-built tree, or compute the MST using the O(n^2) naive algorithm.
*
- * @tparam MetricType The metric to use. IMPORTANT: this hasn't really been
- * tested with anything other than the L2 metric, so user beware. Note that the
- * tree type needs to compute bounds using the same metric as the type
+ * @tparam MetricType The metric to use. IMPORTANT: this hasn't really been
+ * tested with anything other than the L2 metric, so user beware. Note that the
+ * tree type needs to compute bounds using the same metric as the type
* specified here.
* @tparam TreeType Type of tree to use. Should use DTBStat as a statistic.
*/
@@ -152,7 +150,7 @@
//! Total distance of the tree.
double totalDist;
-
+
//! The metric
MetricType metric;
Modified: mlpack/trunk/src/mlpack/methods/emst/dtb_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/emst/dtb_impl.hpp 2013-02-26 22:42:42 UTC (rev 14398)
+++ mlpack/trunk/src/mlpack/methods/emst/dtb_impl.hpp 2013-02-26 22:50:34 UTC (rev 14399)
@@ -26,31 +26,15 @@
/**
* An initializer for leaves.
*/
-template<typename MatType>
-DTBStat::DTBStat(const MatType& /* dataset */,
- const size_t start,
- const size_t count) :
+template<typename TreeType>
+DTBStat::DTBStat(const TreeType& node) :
maxNeighborDistance(DBL_MAX),
- componentMembership((count == 1) ? start : -1)
+ componentMembership(
+ ((node.NumPoints() == 1) && (node.NumChildren() == 0)) ? start : -1)
{
// Nothing to do.
}
-/**
- * An initializer for non-leaves.
- */
-template<typename MatType>
-DTBStat::DTBStat(const MatType& /* dataset */,
- const size_t start,
- const size_t count,
- const DTBStat& /* leftStat */,
- const DTBStat& /* rightStat */) :
- maxNeighborDistance(DBL_MAX),
- componentMembership((count == 1) ? start : -1)
-{
- // Nothing to do.
-}
-
// DualTreeBoruvka
/**
@@ -140,11 +124,11 @@
while (edges.size() < (data.n_cols - 1))
{
-
+
typename TreeType::template DualTreeTraverser<RuleType> traverser(rules);
-
+
traverser.Traverse(*tree, *tree);
-
+
AddAllEdges();
Cleanup();
More information about the mlpack-svn
mailing list