https://github.com/seniverse/vptree
An Erlang implementation of vantage point tree.
https://github.com/seniverse/vptree
erlang-library vantage-point-tree
Last synced: 13 days ago
JSON representation
An Erlang implementation of vantage point tree.
- Host: GitHub
- URL: https://github.com/seniverse/vptree
- Owner: seniverse
- License: apache-2.0
- Created: 2019-07-12T10:56:26.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-12T11:05:16.000Z (almost 6 years ago)
- Last Synced: 2024-09-17T20:07:33.163Z (8 months ago)
- Topics: erlang-library, vantage-point-tree
- Language: Erlang
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## vptree
[](https://travis-ci.org/seniverse/vptree)
[](https://coveralls.io/github/seniverse/vptree?branch=master)
[](https://hex.pm/packages/vptree)
[](https://hex.pm/packages/vptree)

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](./LICENSE) file for more information.