diff --git a/cpp/BayesTree-inl.h b/cpp/BayesTree-inl.h index a7e377250..77238eb64 100644 --- a/cpp/BayesTree-inl.h +++ b/cpp/BayesTree-inl.h @@ -402,10 +402,11 @@ namespace gtsam { // only add if key is not yet in the factor graph if (!factors.involves(key)) { - // get the clique + // get the clique and remove it from orphans (if it exists) sharedClique clique = (*this)[key]; + orphans.remove(clique); - // remove path above this clique + // remove path from clique to root FactorGraph factors1; Cliques orphans1; boost::tie(factors1,orphans1) = removePath(clique); diff --git a/cpp/testBayesTree.cpp b/cpp/testBayesTree.cpp index 70b581664..3b38d68e3 100644 --- a/cpp/testBayesTree.cpp +++ b/cpp/testBayesTree.cpp @@ -364,7 +364,7 @@ TEST( BayesTree, removePath2 ) { SymbolicBayesTree bayesTree = createAsiaSymbolicBayesTree(); - // Call remove-path with clique S + // Call remove-path with clique B FactorGraph factors; SymbolicBayesTree::Cliques orphans; boost::tie(factors,orphans) = bayesTree.removePath(bayesTree["B"]); @@ -427,7 +427,7 @@ TEST( BayesTree, removeTop ) CHECK(assert_equal((FactorGraph)expected, factors)); SymbolicBayesTree::Cliques expectedOrphans; expectedOrphans += bayesTree["T"], bayesTree["X"]; - //CHECK(assert_equal(expectedOrphans, orphans)); + CHECK(assert_equal(expectedOrphans, orphans)); } /* ************************************************************************* */