add nrKeys and set
parent
6355b128fc
commit
0142cc3d3f
|
@ -105,6 +105,14 @@ namespace gtsam {
|
|||
return partitions;
|
||||
}
|
||||
|
||||
// get the nodes in the given tree
|
||||
Set set(const Label& label) {
|
||||
Set set;
|
||||
BOOST_FOREACH(const KeyLabel& pair, (Tree)*this)
|
||||
if (pair.second==label) set.insert(pair.first);
|
||||
return set;
|
||||
}
|
||||
|
||||
/** equality */
|
||||
bool operator==(const Self& t) const { return (Tree)*this == (Tree)t; }
|
||||
|
||||
|
|
|
@ -407,8 +407,7 @@ std::pair<FactorGraph<Factor>, FactorGraph<Factor> > FactorGraph<Factor>::splitM
|
|||
DSF<Symbol> dsf(keys());
|
||||
|
||||
// while G is nonempty and T is not yet spanning
|
||||
size_t m = nrFactors();
|
||||
for (size_t i=0;i<m;i++) {
|
||||
for (size_t i=0;i<size();i++) {
|
||||
const sharedFactor& f = factors_[i];
|
||||
|
||||
// retrieve the labels of all the keys
|
||||
|
|
|
@ -92,6 +92,9 @@ namespace gtsam {
|
|||
/** return keys in some random order */
|
||||
Ordering keys() const;
|
||||
|
||||
/** return the number of the keys */
|
||||
inline size_t nrKeys() const {return indices_.size(); };
|
||||
|
||||
/** Check whether a factor with this variable exists */
|
||||
bool involves(const Symbol& key) const {
|
||||
return !(indices_.find(key)==indices_.end());
|
||||
|
|
|
@ -181,6 +181,20 @@ TEST(DSF, partition3) {
|
|||
CHECK(expected == partitions[dsf.findSet(5)]);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(DSF, set) {
|
||||
DSFInt dsf;
|
||||
dsf = dsf.makeSet(5);
|
||||
dsf = dsf.makeSet(6);
|
||||
dsf = dsf.makeSet(7);
|
||||
dsf = dsf.makeUnion(5,6);
|
||||
set<int> set = dsf.set(5);
|
||||
LONGS_EQUAL(2, set.size());
|
||||
|
||||
std::set<int> expected; expected += 5, 6;
|
||||
CHECK(expected == set);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int func(const int& a) { return a + 10; }
|
||||
TEST(DSF, map) {
|
||||
|
|
Loading…
Reference in New Issue