28 DSFBase::DSFBase(
const size_t numNodes) {
29 v_ = std::make_shared < V > (numNodes);
31 for (V::iterator it = v_->begin(); it != v_->end(); it++, index++)
36 DSFBase::DSFBase(
const std::shared_ptr<V>& v_in) {
39 for (V::iterator it = v_->begin(); it != v_->end(); it++, index++)
44 size_t DSFBase::find(
size_t key)
const {
46 size_t parent = (*v_)[
key];
48 parent = find(parent);
54 void DSFBase::merge(
const size_t& i1,
const size_t& i2) {
55 (*v_)[find(i2)] = find(i1);
59 DSFVector::DSFVector(
const size_t numNodes) :
61 keys_.reserve(numNodes);
62 for (
size_t index = 0; index < numNodes; index++)
63 keys_.push_back(index);
73 const std::vector<size_t>&
keys) :
75 assert(*(std::max_element(keys.begin(), keys.end()))<v_in->size());
94 std::set < size_t >
set;
103 std::map<size_t, std::set<size_t> >
sets;
111 std::map<size_t, std::vector<size_t> >
arrays;
const gtsam::Symbol key('X', 0)
size_t find(size_t key) const
Find the label of the set in which {key} lives.
A faster implementation for DSF, which uses vector rather than btree.
DSFVector(const size_t numNodes)
Constructor that allocates new memory, uses sequential keys 0...numNodes-1.
std::map< size_t, std::vector< size_t > > arrays() const
Return all sets, i.e. a partition of all elements.
std::vector< size_t > keys_
stores keys to support more expensive operations
std::map< size_t, std::set< size_t > > sets() const
Return all sets, i.e. a partition of all elements.
bool isSingleton(const size_t &label) const
Find whether there is one and only one occurrence for the given {label}.
std::set< size_t > set(const size_t &label) const
Get the nodes in the tree with the given label.
static EIGEN_DEPRECATED const end_t end