Fix heuristic selection candidate sourcing

This commit is contained in:
Dirkjan Ochtman 2021-01-19 10:49:56 +01:00
parent 08e1f4e085
commit e4d66890da
1 changed files with 11 additions and 9 deletions

View File

@ -569,17 +569,19 @@ impl Search {
self.working.clear();
// Get input candidates from `self.nearest` and store them in `self.working`.
// `self.candidates` will represent `W` from the paper's algorithm 4 for now.
while let Some(Reverse(candidate)) = self.candidates.pop() {
for &candidate in &self.nearest {
self.working.push(candidate);
for hop in layer.nearest_iter(candidate.pid) {
if !self.visited.insert(hop) {
continue;
}
if params.extend_candidates {
for hop in layer.nearest_iter(candidate.pid) {
if !self.visited.insert(hop) {
continue;
}
let other = &points[hop];
let distance = OrderedFloat::from(point.distance(other));
let new = Candidate { distance, pid: hop };
self.working.push(new);
let other = &points[hop];
let distance = OrderedFloat::from(point.distance(other));
let new = Candidate { distance, pid: hop };
self.working.push(new);
}
}
}