25 #ifndef MLPACK_METHODS_EMST_DTB_HPP 26 #define MLPACK_METHODS_EMST_DTB_HPP 78 typename MatType = arma::mat,
79 template<
typename TreeMetricType,
80 typename TreeStatType,
87 typedef TreeType<MetricType, DTBStat, MatType>
Tree;
140 const bool naive =
false,
141 const MetricType metric = MetricType());
161 const MetricType metric = MetricType());
183 void AddEdge(
const size_t e1,
const size_t e2,
const double distance);
211 #include "dtb_impl.hpp" 213 #endif // MLPACK_METHODS_EMST_DTB_HPP bool naive
Indicates whether or not O(n^2) naive mode will be used.
A Union-Find data structure.
An edge pair is simply two indices and a distance.
const MatType & data
Reference to the data (this is what should be used for accessing data).
Linear algebra utility functions, generally performed on matrices or vectors.
LMetric< 2, true > EuclideanDistance
The Euclidean (L2) distance.
The core includes that mlpack expects; standard C++ includes and Armadillo.
std::vector< EdgePair > edges
Edges.
struct mlpack::emst::DualTreeBoruvka::SortEdgesHelper SortFun
void Cleanup()
The values stored in the tree must be reset on each iteration.
MetricType metric
The instantiated metric.
bool ownTree
Indicates whether or not we "own" the tree.
A binary space partitioning tree, such as a KD-tree or a ball tree.
void ComputeMST(arma::mat &results)
Iteratively find the nearest neighbor of each component until the MST is complete.
arma::Col< size_t > neighborsOutComponent
List of edge nodes.
bool operator()(const EdgePair &pairA, const EdgePair &pairB)
DualTreeBoruvka(const MatType &dataset, const bool naive=false, const MetricType metric=MetricType())
Create the tree from the given dataset.
void EmitResults(arma::mat &results)
Unpermute the edge list and output it to results.
double totalDist
Total distance of the tree.
~DualTreeBoruvka()
Delete the tree, if it was created inside the object.
std::vector< size_t > oldFromNew
Permutations of points during tree building.
TreeType< MetricType, DTBStat, MatType > Tree
Convenience typedef.
For sorting the edge list after the computation.
arma::vec neighborsDistances
List of edge distances.
void CleanupHelper(Tree *tree)
This function resets the values in the nodes of the tree nearest neighbor distance, and checks for fully connected nodes.
UnionFind connections
Connections.
arma::Col< size_t > neighborsInComponent
List of edge nodes.
Performs the MST calculation using the Dual-Tree Boruvka algorithm, using any type of tree...
double Distance() const
Get the distance.
Tree * tree
Pointer to the root of the tree.
void AddEdge(const size_t e1, const size_t e2, const double distance)
Adds a single edge to the edge list.
void AddAllEdges()
Adds all the edges found in one iteration to the list of neighbors.