diff --git a/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs b/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs index 4a696b3dd..738b53016 100644 --- a/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs +++ b/milli/src/search/new/ranking_rule_graph/cheapest_paths.rs @@ -235,6 +235,9 @@ impl RankingRuleGraph { node_with_removed_outgoing_conditions: Interned, costs: &mut MappedInterner>, ) { + // Traverse the graph backward from the target node, recomputing the cost for each of its predecessors. + // We first check that no other node is contributing the same total cost to a predecessor before removing + // the cost from the predecessor. self.traverse_breadth_first_backward(node_with_removed_outgoing_conditions, |cur_node| { let mut costs_to_remove = FxHashSet::default(); costs_to_remove.extend(costs.get(cur_node).iter().copied());