diff --git a/cpp/BayesTree-inl.h b/cpp/BayesTree-inl.h index 5c9a57293..d3b56806d 100644 --- a/cpp/BayesTree-inl.h +++ b/cpp/BayesTree-inl.h @@ -344,26 +344,32 @@ namespace gtsam { ordering += key1, key2; return eliminate(fg,ordering); } - +#if 0 /* ************************************************************************* */ template template - FactorGraph + std::pair, std::list > BayesTree::removePath(sharedClique clique) { // base case is NULL, return empty factor graph - if (clique==NULL) return FactorGraph(); + if (clique==NULL) { + list orphans; + return make_pair(), orphans>; + } // remove path above me - FactorGraph factors = removePath(clique->parent_); + std::pair, std::list > factors_orphans = removePath(clique->parent_); + + // add children to list of orphans + factors_orphans.second.insert(factors_orphans.second.begin(), clique->children_.begin(), clique->children_.end()); // remove me and add my factors removeClique(clique); factors.push_back(*clique); - return factors; + return factors_orphans; } - +#endif /* ************************************************************************* */ } diff --git a/cpp/BayesTree.h b/cpp/BayesTree.h index 422896f07..29c29ce3c 100644 --- a/cpp/BayesTree.h +++ b/cpp/BayesTree.h @@ -154,11 +154,11 @@ namespace gtsam { /** return joint on two variables as a BayesNet */ template BayesNet jointBayesNet(const std::string& key1, const std::string& key2) const; - - /** Remove path from clique to root and return that path as factors */ +#if 0 + /** Remove path from clique to root and return that path as factors plus a list of orphaned subtree roots */ template - FactorGraph removePath(sharedClique clique); - + std::pair, std::list > removePath(sharedClique clique); +#endif }; // BayesTree } /// namespace gtsam diff --git a/cpp/testBayesTree.cpp b/cpp/testBayesTree.cpp index f7768d61c..bfc12275d 100644 --- a/cpp/testBayesTree.cpp +++ b/cpp/testBayesTree.cpp @@ -331,16 +331,18 @@ TEST( BayesTree, removePath ) expected.push_factor("A","B"); expected.push_factor("A"); expected.push_factor("A","C"); - - SymbolicFactorGraph actual = bayesTree.removePath(bayesTree["C"]); - CHECK(assert_equal(expected, actual)); +#if 0 + std::pair, std::list > actual = + bayesTree.removePath(bayesTree["C"]); + CHECK(assert_equal(expected, actual.first)); // remove E: factor graph with EB; E|B removed from second orphan tree SymbolicFactorGraph expected3; expected3.push_factor("B","E"); actual = bayesTree.removePath(bayesTree["E"]); - CHECK(assert_equal(expected3, actual)); + CHECK(assert_equal(expected3, actual.first)); +#endif } /* ************************************************************************* */