Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dellaert committed Jan 28, 2025
1 parent 9e98b80 commit 8c7e75b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions gtsam/discrete/DiscreteJunctionTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,18 @@ DiscreteJunctionTree::DiscreteJunctionTree(
const DiscreteEliminationTree& eliminationTree)
: Base(eliminationTree) {}
/* ************************************************************************* */
namespace {
struct PrintForestVisitorPre {
const KeyFormatter& formatter;
PrintForestVisitorPre(const KeyFormatter& formatter) : formatter(formatter) {}
std::string operator()(
const std::shared_ptr<DiscreteJunctionTree::Cluster>& node,
const std::string& parentString) {
// Print the current node
node->print(parentString + "-", formatter);
node->factors.print(parentString + "-", formatter);
std::cout << std::endl;
// Increment the indentation
return parentString + "| ";
}
};
} // namespace

void DiscreteJunctionTree::print(const std::string& s,
const KeyFormatter& keyFormatter) const {
PrintForestVisitorPre visitor(keyFormatter);
auto visitor = [&keyFormatter](
const std::shared_ptr<DiscreteJunctionTree::Cluster>& node,
const std::string& parentString) {
// Print the current node
node->print(parentString + "-", keyFormatter);
node->factors.print(parentString + "-", keyFormatter);
std::cout << std::endl;
return parentString + "| "; // Increment the indentation
};
std::string parentString = s;
treeTraversal::DepthFirstForest(*this, parentString, visitor);
}
Expand Down
2 changes: 1 addition & 1 deletion gtsam/discrete/tests/AsiaExample.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ DiscreteBayesNet createAsiaExample() {
return asia;
}
} // namespace asia_example
} // namespace gtsam
} // namespace gtsam

0 comments on commit 8c7e75b

Please sign in to comment.