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
| 386 | } |
| 387 | |
| 388 | fn merge_candidate( |
| 389 | candidates: &mut HashMap<String, CandidateScore>, |
| 390 | node_id: &str, |
| 391 | path: Option<String>, |
| 392 | base: f64, |
| 393 | neighbor: bool, |
| 394 | ) { |
| 395 | candidates |
| 396 | .entry(node_id.to_string()) |
| 397 | .and_modify(|candidate| { |
| 398 | candidate.base = candidate.base.max(base); |
| 399 | candidate.neighbor |= neighbor; |
| 400 | if candidate.path.is_none() { |
| 401 | candidate.path = path.clone(); |
| 402 | } |
| 403 | }) |
| 404 | .or_insert(CandidateScore { |
| 405 | base, |
| 406 | neighbor, |
| 407 | path, |
| 408 | }); |
| 409 | } |
| 410 | |
| 411 | /// Add all memory nodes adjacent to `node_id` as neighbor candidates. |
| 412 | fn add_memory_neighbors( |