summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 13:55:33 +0400
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 13:55:33 +0400
commit25c1742d43e6e710ffb520525df6c31f684b0174 (patch)
tree180c1e251b852b7af45951bd392f20d08a685d56
parent32f051856bd097ec9b1118c792c0f7d8cde09bc7 (diff)
avoid divide par zero
-rw-r--r--autofeur_db/src/trie.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/autofeur_db/src/trie.rs b/autofeur_db/src/trie.rs
index 5ffd097..b202a97 100644
--- a/autofeur_db/src/trie.rs
+++ b/autofeur_db/src/trie.rs
@@ -129,7 +129,7 @@ impl<'a> Trie<'a> {
// If this node is final and has childrens
if current_node.is_final && current_node.child_count > 0 {
// choose from current node or continue with childrens
- let weighted = WeightedIndex::new(&[1, current_node.child_count / length])
+ let weighted = WeightedIndex::new(&[1, current_node.child_count / (length + 1)])
.expect("distribution seems impossible");
if weighted.sample(&mut rng) == 0 {