vptree

vantage point tree


License
Apache-2.0

Documentation

vptree

Build Status Coverage Status hex.pm version hex.pm downloads hex.pm license GitHub top language

An Erlang implementation of vantage point tree.

Usage

Define a distance function

1> Distance = fun({X1,Y1},{X2,Y2}) -> X = X2-X1, Y = Y2-Y1, math:sqrt(X*X+Y*Y) end.

Create vantage point tree from a list of points

2> Tree = vptree:from_list(Distance, [{{0.0, 0.0}, a}, {{1.0, 1.0}, b}]).

Find nearest point within a given distance

3>  vptree:search(Distance, {0.2,0.2}, 100.0, not_found, Tree).
a
4> vptree:search(Distance, {0.2,0.2}, 0.1, not_found, Tree).  
not_found

Installation

add vptree dependency to your project's rebar.config

{deps, [vptree]}.

License

vptree is released under Apache 2 License. Check LICENSE file for more information.