#avl-tree #nearest-neighbor #metrics #point #insertion #vp #updateable

nightly vp-avl

A combined Vantage-Point AVL tree, to make VP trees updateable

6 releases

0.1.5 Apr 4, 2024
0.1.4 Feb 19, 2024

#7 in #avl-tree

Download history 310/week @ 2024-02-13 79/week @ 2024-02-20 34/week @ 2024-02-27 132/week @ 2024-04-02 7/week @ 2024-04-09 67/week @ 2024-04-16

206 downloads per month

MIT/Apache

32KB
639 lines

VP-AVL

This provides a novel type of VP-tree that also integrates features of an AVL tree, which allows insertion into the tree without complete rebuilding. In practice building the tree in bulk is still faster (empirically by about 40% for a tree with 1000 elements up to about a factor of 2.5 for a tree of 1,000,000), but obviously still much faster than rebuilding the tree upon every insertion.

To bulk insert with the provided Euclidean Metric and some type which implements IntoIterator, simply:

        let random_points = k_random(10000);

        let avl = VpAvl::bulk_insert(EuclideanMetric::default(), random_points);

or iteratively:

        let random_points = k_random(10000);

        let avl = VpAvl::new(EuclideanMetric::default());

        for point in random_points{
            avl.insert(point)
        }

To iterate through the nearest neighbors to a points, call nn_iter:

    let query_point = vec![1.0,1.0,2.0,3.0,5.0];

    for point in avl.nn_iter(&query_point){
        ...
    }

Dependencies

~310KB