[involves] checks whether variable with that key is involved in any factor

release/4.3a0
Frank Dellaert 2009-11-20 05:14:34 +00:00
parent 6aba2f1c1c
commit 55e85fd8a5
2 changed files with 15 additions and 0 deletions

View File

@ -92,6 +92,11 @@ namespace gtsam {
/** return keys in some random order */
Ordering keys() const;
/** Check whether a factor with this variable exists */
bool involves(const std::string& key) {
return !(indices_.find(key)==indices_.end());
}
/**
* Compute colamd ordering
*/

View File

@ -527,6 +527,16 @@ TEST( GaussianFactorGraph, keys )
CHECK(assert_equal(expected,fg.keys()));
}
/* ************************************************************************* */
TEST( GaussianFactorGraph, involves )
{
GaussianFactorGraph fg = createGaussianFactorGraph();
CHECK(fg.involves("l1"));
CHECK(fg.involves("x1"));
CHECK(fg.involves("x2"));
CHECK(!fg.involves("x3"));
}
/* ************************************************************************* */
// Tests ported from ConstrainedGaussianFactorGraph
/* ************************************************************************* */