Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtchavez/bk-tree-erl
Erlang BK-Tree
https://github.com/mtchavez/bk-tree-erl
bk-tree erlang
Last synced: 19 days ago
JSON representation
Erlang BK-Tree
- Host: GitHub
- URL: https://github.com/mtchavez/bk-tree-erl
- Owner: mtchavez
- License: mit
- Created: 2013-03-29T04:57:47.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-12T04:20:24.000Z (over 7 years ago)
- Last Synced: 2023-03-17T04:45:31.173Z (almost 2 years ago)
- Topics: bk-tree, erlang
- Language: Erlang
- Size: 19.5 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Erlang BK-Tree
[![Build Status](https://travis-ci.org/mtchavez/bk-tree-erl.png?branch=master)](https://travis-ci.org/mtchavez/bk-tree-erl)
## Filling tree
In the Erlang console initialize a tree with a root node
```erlang
cd("./src").
c("bk_trees").
T = bk_trees:init("brewery").
```Then add some more terms to the tree
```erlang
T2 = bk_trees:insert("stone", T).
T3 = bk_trees:insert("anchorsteam", T2).
T4 = bk_trees:insert("delirium", T3).
```## Searching
Once you have populated the tree you can do a search.
Default depth is ```1``` when doing a search.
```erlang
bk_trees:search("budweiser", T4).
% returns []
```Increasing the depth will give you more terms that are close to your search term.
```erlang
bk_trees:search("deli", T4, 4).
% returns [{4,"delirium"}]bk_trees:search("deli", T4, 5).
% returns [{5,"stone"},{4,"delirium"}]
```## Tests
Run using ```make test```