summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 2407ebc1d01d19cd4b52366929543a23d551c334 (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
`acap`
======

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tavianator/knn/blob/master/LICENSE)
[![Build Status](https://travis-ci.com/tavianator/acap.svg?branch=master)](https://travis-ci.com/tavianator/acap)

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);
```