mirror of
https://github.com/instant-labs/instant-distance.git
synced 2025-02-09 01:12:03 +00:00
Fix neighbor updates for heuristic searches
This commit is contained in:
parent
58a7162d0a
commit
c03cec4458
11
src/lib.rs
11
src/lib.rs
@ -393,9 +393,16 @@ fn insert<P: Point>(
|
||||
|
||||
let found =
|
||||
insertion.select_heuristic(&layer, M * 2, candidate_point, points, *heuristic);
|
||||
for (slot, hop) in layer[pid].nearest.iter_mut().zip(found) {
|
||||
*slot = hop.pid;
|
||||
for (i, slot) in layer[pid].nearest.iter_mut().enumerate() {
|
||||
if let Some(&Candidate { pid, .. }) = found.get(i) {
|
||||
*slot = pid;
|
||||
} else if *slot != PointId::invalid() {
|
||||
*slot = PointId::invalid();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
layer[new].nearest[i] = pid;
|
||||
} else {
|
||||
// Find the correct index to insert at to keep the neighbor's neighbors sorted
|
||||
|
Loading…
Reference in New Issue
Block a user