Function
merge_candidate
(
candidates: &mut HashMap<String, CandidateScore>,
node_id: &str,
path: Option<String>,
base: f64,
neighbor: bool,
)
Source from the content-addressed store, hash-verified
| 425 | } |
| 426 | |
| 427 | fn merge_candidate( |
| 428 | candidates: &mut HashMap<String, CandidateScore>, |
| 429 | node_id: &str, |
| 430 | path: Option<String>, |
| 431 | base: f64, |
| 432 | neighbor: bool, |
| 433 | ) { |
| 434 | candidates |
| 435 | .entry(node_id.to_string()) |
| 436 | .and_modify(|candidate| { |
| 437 | candidate.base = candidate.base.max(base); |
| 438 | candidate.neighbor |= neighbor; |
| 439 | if candidate.path.is_none() { |
| 440 | candidate.path = path.clone(); |
| 441 | } |
| 442 | }) |
| 443 | .or_insert(CandidateScore { |
| 444 | base, |
| 445 | neighbor, |
| 446 | path, |
| 447 | }); |
| 448 | } |
| 449 | |
| 450 | /// Add all memory nodes adjacent to `node_id` as neighbor candidates. |
| 451 | fn add_memory_neighbors( |