#nearest-neighbor #search-algorithms #knn #ball-tree

petal-neighbors

Nearest neighbor search algorithms including a ball tree and a vantage point tree

14 releases (breaking)

0.11.0 Aug 8, 2024
0.10.0 Dec 20, 2023
0.9.0 Aug 7, 2023
0.8.0 Apr 19, 2022
0.1.0 Nov 21, 2019

#165 in Algorithms

Download history 418/week @ 2024-07-29 466/week @ 2024-08-05 403/week @ 2024-08-12 449/week @ 2024-08-19 679/week @ 2024-08-26 697/week @ 2024-09-02 688/week @ 2024-09-09 455/week @ 2024-09-16 980/week @ 2024-09-23 849/week @ 2024-09-30 866/week @ 2024-10-07 614/week @ 2024-10-14 663/week @ 2024-10-21 485/week @ 2024-10-28 973/week @ 2024-11-04 538/week @ 2024-11-11

2,678 downloads per month
Used in 4 crates (3 directly)

Apache-2.0

42KB
973 lines

petal-neighbors

Nearest neighbor search algorithms including a ball tree and a vantage point tree.

crates.io Documentation Coverage Status

Examples

The following example shows how to find two nearest neighbors in a ball tree.

use ndarray::{array, aview1};
use petal_neighbors::BallTree;

let points = array![[1., 1.], [1., 2.], [9., 9.]];
let tree = BallTree::euclidean(points).unwrap();
let (indices, distances) = tree.query(&aview1(&[3., 3.]), 2);
assert_eq!(indices, &[1, 0]);  // points[1] is the nearest, points[0] the next.

License

Copyright 2019-2024 Petabi, Inc.

Licensed under Apache License, Version 2.0 (the "License"); you may not use this crate except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See LICENSE for the specific language governing permissions and limitations under the License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Dependencies

~1.6–2.3MB
~47K SLoC