项目作者: mtchavez

项目描述 :
Erlang BK-Tree
高级语言: Erlang
项目地址: git://github.com/mtchavez/bk-tree-erl.git
创建时间: 2013-03-29T04:57:47Z
项目社区:https://github.com/mtchavez/bk-tree-erl

开源协议:MIT License

下载


Erlang BK-Tree

Build Status

Filling tree

In the Erlang console initialize a tree with a root node

  1. cd("./src").
  2. c("bk_trees").
  3. T = bk_trees:init("brewery").

Then add some more terms to the tree

  1. T2 = bk_trees:insert("stone", T).
  2. T3 = bk_trees:insert("anchorsteam", T2).
  3. 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.

  1. bk_trees:search("budweiser", T4).
  2. % returns []

Increasing the depth will give you more terms that are close to your search term.

  1. bk_trees:search("deli", T4, 4).
  2. % returns [{4,"delirium"}]
  3. bk_trees:search("deli", T4, 5).
  4. % returns [{5,"stone"},{4,"delirium"}]

Tests

Run using make test