From d1246bfe987be28118c805f6232ffcb188ec1522 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Sun, 27 Jan 2013 20:12:22 +0000 Subject: [PATCH] Added empty() to BayesTree --- gtsam/inference/BayesTree.h | 5 +++++ gtsam/inference/tests/testBayesTree.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/gtsam/inference/BayesTree.h b/gtsam/inference/BayesTree.h index 3982a5987..8e09da31d 100644 --- a/gtsam/inference/BayesTree.h +++ b/gtsam/inference/BayesTree.h @@ -162,6 +162,11 @@ namespace gtsam { return 0; } + /** Check if there are any cliques in the tree */ + inline bool empty() const { + return nodes_.empty(); + } + /** return nodes */ const Nodes& nodes() const { return nodes_; } diff --git a/gtsam/inference/tests/testBayesTree.cpp b/gtsam/inference/tests/testBayesTree.cpp index bbc02e07c..a29b609a5 100644 --- a/gtsam/inference/tests/testBayesTree.cpp +++ b/gtsam/inference/tests/testBayesTree.cpp @@ -93,6 +93,7 @@ TEST( BayesTree, constructor ) // Check Size LONGS_EQUAL(4,bayesTree.size()); + EXPECT(!bayesTree.empty()); // Check root boost::shared_ptr actual_root = bayesTree.root()->conditional(); @@ -155,6 +156,7 @@ TEST( BayesTree, removePath ) E(new IndexConditional(_E_, _B_)), F(new IndexConditional(_F_, _E_)); SymbolicBayesTree bayesTree; + EXPECT(bayesTree.empty()); // Ordering ord; ord += _A_,_B_,_C_,_D_,_E_,_F_; SymbolicBayesTree::insert(bayesTree, A); SymbolicBayesTree::insert(bayesTree, B);