From e5fea0da5204a1d9e48226e9eef4175a77e3d8fd Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Mon, 26 Jun 2023 18:16:43 -0400 Subject: [PATCH] update docstring --- gtsam/discrete/DecisionTree-inl.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gtsam/discrete/DecisionTree-inl.h b/gtsam/discrete/DecisionTree-inl.h index 8dc19ea21..b65cc6bcf 100644 --- a/gtsam/discrete/DecisionTree-inl.h +++ b/gtsam/discrete/DecisionTree-inl.h @@ -199,11 +199,26 @@ namespace gtsam { #endif } - /// If all branches of a choice node f are the same, just return a branch. + /** + * @brief Merge branches with equal leaf values for every choice node in a + * decision tree. If all branches are the same (i.e. have the same leaf + * value), replace the choice node with the equivalent leaf node. + * + * This function applies the branch merging (if enabled) recursively on the + * decision tree represented by the root node passed in as the argument. It + * recurses to the leaf nodes and merges branches with equal leaf values in + * a bottom-up fashion. + * + * Thus, if all branches of a choice node `f` are the same, + * just return a single branch at each recursion step. + * + * @param node The root node of the decision tree. + * @return NodePtr + */ static NodePtr Unique(const NodePtr& node) { if (auto choice = std::dynamic_pointer_cast(node)) { // Choice node, we recurse! - // Make non-const copy + // Make non-const copy so we can update auto f = std::make_shared(choice->label(), choice->nrChoices()); // Iterate over all the branches