blob: a2545268b18d58128a96e9c1e7be76c5e8728c12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
`acap`
======
[](https://crates.io/crates/acap)
[](https://docs.rs/acap)
[](https://github.com/tavianator/knn/blob/main/LICENSE)
[](https://github.com/tavianator/acap/actions/workflows/ci.yml)
As Close As Possible — [nearest neighbor search] in Rust.
[nearest neighbor search]: https://en.wikipedia.org/wiki/Nearest_neighbor_search
Example
-------
```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);
```
|