Crates.io | acap |
lib.rs | acap |
version | 0.3.0 |
source | src |
created_at | 2020-06-24 15:05:55.622818 |
updated_at | 2021-10-24 15:57:37.658884 |
description | As Close As Possible — nearest neighbor search in Rust. |
homepage | |
repository | https://github.com/tavianator/acap |
max_upload_size | |
id | 257593 |
size | 108,360 |
acap
As Close As Possible — nearest neighbor search in Rust.
use acap::euclid::Euclidean;
use acap::vp::VpTree;
use acap::NearestNeighbors;
let tree = VpTree::balanced(vec![
Euclidean([3, 4]),
Euclidean([5, 12]),
Euclidean([8, 15]),
Euclidean([7, 24]),
]);
let nearest = tree.nearest(&[7, 7]).unwrap();
assert_eq!(nearest.item, &Euclidean([3, 4]));
assert_eq!(nearest.distance, 5);