spread: separate traversal from ranking
Node weight no longer gates signal propagation — only edge_decay and edge_strength affect traversal. Node weight is applied at the end for ranking. This lets low-weight nodes serve as bridges without killing the signal passing through them. Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
parent
05c7d55949
commit
1326a683a5
1 changed files with 10 additions and 3 deletions
|
|
@ -656,13 +656,14 @@ fn spreading_activation(
|
|||
}
|
||||
|
||||
// Propagate hop by hop — all sources simultaneously
|
||||
// Node weight does NOT gate traversal — only edge_decay and edge strength.
|
||||
// Node weight is applied at the end for ranking.
|
||||
for _hop in 0..max_hops {
|
||||
let mut next_frontier: HashMap<String, f64> = HashMap::new();
|
||||
|
||||
for (key, act) in &frontier {
|
||||
for (neighbor, strength) in graph.neighbors(key) {
|
||||
let neighbor_weight = store.node_weight(neighbor.as_str());
|
||||
let propagated = act * edge_decay * neighbor_weight * strength as f64;
|
||||
let propagated = act * edge_decay * strength as f64;
|
||||
if propagated < min_activation { continue; }
|
||||
|
||||
*next_frontier.entry(neighbor.clone()).or_insert(0.0) += propagated;
|
||||
|
|
@ -678,7 +679,13 @@ fn spreading_activation(
|
|||
frontier = next_frontier;
|
||||
}
|
||||
|
||||
let mut results: Vec<_> = activation.into_iter().collect();
|
||||
// Apply node weight for ranking, not traversal
|
||||
let mut results: Vec<_> = activation.into_iter()
|
||||
.map(|(key, act)| {
|
||||
let weight = store.node_weight(&key);
|
||||
(key, act * weight)
|
||||
})
|
||||
.collect();
|
||||
results.sort_by(|a, b| b.1.total_cmp(&a.1));
|
||||
results
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue