Added empty() to BayesTree

release/4.3a0
Alex Cunningham 2013-01-27 20:12:22 +00:00
parent 5a9e2a42ec
commit d1246bfe98
2 changed files with 7 additions and 0 deletions

View File

@ -162,6 +162,11 @@ namespace gtsam {
return 0; return 0;
} }
/** Check if there are any cliques in the tree */
inline bool empty() const {
return nodes_.empty();
}
/** return nodes */ /** return nodes */
const Nodes& nodes() const { return nodes_; } const Nodes& nodes() const { return nodes_; }

View File

@ -93,6 +93,7 @@ TEST( BayesTree, constructor )
// Check Size // Check Size
LONGS_EQUAL(4,bayesTree.size()); LONGS_EQUAL(4,bayesTree.size());
EXPECT(!bayesTree.empty());
// Check root // Check root
boost::shared_ptr<IndexConditional> actual_root = bayesTree.root()->conditional(); boost::shared_ptr<IndexConditional> actual_root = bayesTree.root()->conditional();
@ -155,6 +156,7 @@ TEST( BayesTree, removePath )
E(new IndexConditional(_E_, _B_)), E(new IndexConditional(_E_, _B_)),
F(new IndexConditional(_F_, _E_)); F(new IndexConditional(_F_, _E_));
SymbolicBayesTree bayesTree; SymbolicBayesTree bayesTree;
EXPECT(bayesTree.empty());
// Ordering ord; ord += _A_,_B_,_C_,_D_,_E_,_F_; // Ordering ord; ord += _A_,_B_,_C_,_D_,_E_,_F_;
SymbolicBayesTree::insert(bayesTree, A); SymbolicBayesTree::insert(bayesTree, A);
SymbolicBayesTree::insert(bayesTree, B); SymbolicBayesTree::insert(bayesTree, B);