forked from Mirror/pve-network
make weighted probabilities depending on node's children children count
This commit is contained in:
parent
e3f5437ed8
commit
16e9f11a3d
|
@ -109,11 +109,11 @@ impl<'a> Trie<'a> {
|
||||||
while current_node.child_nodes.len() != 0 {
|
while current_node.child_nodes.len() != 0 {
|
||||||
// We need to choose a random child based on weights
|
// We need to choose a random child based on weights
|
||||||
let weighted = WeightedIndex::new(current_node.child_nodes.iter().map(|(_, node)| {
|
let weighted = WeightedIndex::new(current_node.child_nodes.iter().map(|(_, node)| {
|
||||||
node.child_count / node
|
node.child_count / (node
|
||||||
.child_nodes
|
.child_nodes
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, b)| b.child_count)
|
.map(|(_, b)| b.child_count)
|
||||||
.sum::<u64>()
|
.sum::<u64>() + 1)
|
||||||
}))
|
}))
|
||||||
.expect("distribution creation should be valid");
|
.expect("distribution creation should be valid");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue