Trait space::KnnPoints[][src]

pub trait KnnPoints: Knn {
    fn get_point(&self, index: Self::Ix) -> &Self::Point;

    fn knn_points(
        &self,
        query: &Self::Point,
        num: usize
    ) -> Vec<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Point)> { ... }
fn nn_point(
        &self,
        query: &Self::Point
    ) -> Option<(Neighbor<<Self::Metric as Metric<Self::Point>>::Unit, Self::Ix>, &Self::Point)> { ... } }
Expand description

This trait gives knn search collections the ability to give the nearest neighbor points back.

This is not the final API. Eventually, the iterator type will be chosen by the collection, but for now it is a Vec until Rust stabilizes GATs.

Required methods

Get a point using a neighbor index returned by Knn::knn or Knn::nn.

This should only be used directly after one of the mentioned methods are called to retrieve a point associated with a neighbor, and will panic if the index is incorrect due to mutating the data structure thereafter. The index is only valid up until the next mutation.

Provided methods

Get num nearest neighbor points of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Get the nearest neighbor point of target.

For many KNN search algorithms, the returned neighbors are approximate, and may not be the actual nearest neighbors.

Implementors