edge_pair.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_EMST_EDGE_PAIR_HPP
15 #define MLPACK_METHODS_EMST_EDGE_PAIR_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 #include "union_find.hpp"
20 
21 namespace mlpack {
22 namespace emst {
23 
28 class EdgePair
29 {
30  private:
32  size_t lesser;
34  size_t greater;
36  double distance;
37 
38  public:
45  EdgePair(const size_t lesser, const size_t greater, const double dist) :
46  lesser(lesser), greater(greater), distance(dist)
47  {
48  Log::Assert(lesser != greater,
49  "EdgePair::EdgePair(): indices cannot be equal.");
50  }
51 
53  size_t Lesser() const { return lesser; }
55  size_t& Lesser() { return lesser; }
56 
58  size_t Greater() const { return greater; }
60  size_t& Greater() { return greater; }
61 
63  double Distance() const { return distance; }
65  double& Distance() { return distance; }
66 }; // class EdgePair
67 
68 } // namespace emst
69 } // namespace mlpack
70 
71 #endif // MLPACK_METHODS_EMST_EDGE_PAIR_HPP
size_t Greater() const
Get the greater index.
Definition: edge_pair.hpp:58
An edge pair is simply two indices and a distance.
Definition: edge_pair.hpp:28
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void Assert(bool condition, const std::string &message="Assert Failed.")
Checks if the specified condition is true.
double & Distance()
Modify the distance.
Definition: edge_pair.hpp:65
size_t Lesser() const
Get the lesser index.
Definition: edge_pair.hpp:53
double Distance() const
Get the distance.
Definition: edge_pair.hpp:63
EdgePair(const size_t lesser, const size_t greater, const double dist)
Initialize an EdgePair with two indices and a distance.
Definition: edge_pair.hpp:45
size_t & Lesser()
Modify the lesser index.
Definition: edge_pair.hpp:55
size_t & Greater()
Modify the greater index.
Definition: edge_pair.hpp:60