Merge pull request #126 from ericschief/cover-tree-fix
Fix issue with cover tree k-nearest neighbors
This commit is contained in:
@@ -180,6 +180,9 @@ impl<T: Debug + PartialEq, F: RealNumber, D: Distance<T, F>> CoverTree<T, F, D>
|
||||
}
|
||||
}
|
||||
|
||||
if neighbors.len() > k {
|
||||
neighbors.sort_by(|a, b| a.1.partial_cmp(&b.1).unwrap());
|
||||
}
|
||||
Ok(neighbors.into_iter().take(k).collect())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user