adds docstring
parent
3b745d39e8
commit
b20827b2dc
|
|
@ -53,6 +53,12 @@ inline std::vector<size_t> sortedIndices(const std::vector<double> &src) {
|
||||||
template <class Graph>
|
template <class Graph>
|
||||||
std::vector<size_t> kruskal(const Graph &fg,
|
std::vector<size_t> kruskal(const Graph &fg,
|
||||||
const std::vector<double> &weights) {
|
const std::vector<double> &weights) {
|
||||||
|
if (fg.size() != weights.size()) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"kruskal() failure: fg.size() != weights.size(), all factors need to "
|
||||||
|
"assigned a weight");
|
||||||
|
}
|
||||||
|
|
||||||
// Create an index from variables to factor indices.
|
// Create an index from variables to factor indices.
|
||||||
const VariableIndex variableIndex(fg);
|
const VariableIndex variableIndex(fg);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,11 @@
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file SubgraphBuilder-inl.h
|
* @file kruskal.h
|
||||||
* @date Dec 31, 2009
|
* @date Dec 31, 2009
|
||||||
* @author Frank Dellaert, Yong-Dian Jian
|
* @author Frank Dellaert
|
||||||
|
* @author Yong-Dian Jian
|
||||||
|
* @author Ankur Roy Chowdhury
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -22,9 +24,17 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace gtsam::utils {
|
namespace gtsam::utils {
|
||||||
|
/**
|
||||||
|
* Compute the minimum spanning tree (MST) using Kruskal's algorithm
|
||||||
|
* @param fg Factor graph
|
||||||
|
* @param weights Weights of the edges/factors in the factor graph
|
||||||
|
* @return Edge/factor indices spanning the MST
|
||||||
|
* @note Only binary factors are considered while constructing the spanning tree
|
||||||
|
* @note The indices of 'weights' should match the indices of the edges in the factor graph
|
||||||
|
*/
|
||||||
template <class FactorGraph>
|
template <class FactorGraph>
|
||||||
std::vector<size_t> kruskal(const FactorGraph &fg,
|
std::vector<size_t> kruskal(const FactorGraph &fg,
|
||||||
const std::vector<double> &weights);
|
const std::vector<double> &weights);
|
||||||
}
|
} // namespace gtsam::utils
|
||||||
|
|
||||||
#include <gtsam/base/kruskal-inl.h>
|
#include <gtsam/base/kruskal-inl.h>
|
||||||
Loading…
Reference in New Issue