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
| 453 | } |
| 454 | |
| 455 | fn merge_candidate( |
| 456 | candidates: &mut HashMap<String, CandidateScore>, |
| 457 | node_id: &str, |
| 458 | path: Option<String>, |
| 459 | base: f64, |
| 460 | neighbor: bool, |
| 461 | ) { |
| 462 | candidates |
| 463 | .entry(node_id.to_string()) |
| 464 | .and_modify(|candidate| { |
| 465 | candidate.base = candidate.base.max(base); |
| 466 | candidate.neighbor |= neighbor; |
| 467 | if candidate.path.is_none() { |
| 468 | candidate.path = path.clone(); |
| 469 | } |
| 470 | }) |
| 471 | .or_insert(CandidateScore { |
| 472 | base, |
| 473 | neighbor, |
| 474 | path, |
| 475 | }); |
| 476 | } |
| 477 | |
| 478 | /// Add all memory nodes adjacent to `node_id` as neighbor candidates. |
| 479 | fn add_memory_neighbors( |