Go to the documentation of this file.
36 inline std::vector<size_t>
sortedIndices(
const std::vector<double> &weights) {
38 const size_t n = weights.size();
46 [&weights](
const size_t i0,
const size_t i1) {
47 return weights[i0] < weights[i1];
54 template <
class FACTOR>
56 const std::vector<double> &weights) {
57 if (fg.
size() != weights.size()) {
58 throw std::runtime_error(
59 "kruskal() failure: fg.size() != weights.size(), all factors need to "
71 const size_t n = variableIndex.
size();
72 std::vector<size_t> treeIndices;
73 treeIndices.reserve(
n - 1);
81 const auto factor = fg[index];
84 if (factor->size() != 2)
continue;
88 const auto u = dsf.
find(factor->front()),
v = dsf.
find(factor->back());
91 const bool loop = (u ==
v);
97 treeIndices.push_back(index);
100 if (++count ==
n - 1)
break;
std::vector< size_t > kruskal(const FactorGraph< FACTOR > &fg, const std::vector< double > &weights)
Typedefs for easier changing of types.
std::vector< size_t > sortedIndices(const std::vector< double > &weights)
Allow for arbitrary type in DSF.
KEY find(const KEY &key) const
Given key, find the representative key for the set in which it lives.
void merge(const KEY &x, const KEY &y)
Merge two sets.
size_t size() const
The number of variable entries. This is equal to the number of unique variable Keys.
Array< int, Dynamic, 1 > v
A thin wrapper around std::map that uses boost's fast_pool_allocator.
gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:02