Bktree
implementation of bk-tree for golang
Install / Use
/learn @agatan/BktreeREADME
bktree
This is an implementation of BK-tree for golang. BK-tree is a tree data structure for similarity search in a metric space. Using BK-tree, you can search neighbors of a data from the metric space efficiently.
Performance
Search similar values from 1,000,000 data.
Data is 64 bits integer, and distance function is hamming distance.
(see bktree_test.go for detail)
BenchmarkSearch_ExactForLargeTree-2 1000000 3540 ns/op
BenchmarkSearch_Tolerance1ForLargeTree-2 30000 85227 ns/op
BenchmarkSearch_Tolerance2ForLargeTree-2 3000 907897 ns/op
BenchmarkSearch_Tolerance4ForLargeTree-2 200 17273811 ns/op
BenchmarkSearch_Tolerance8ForLargeTree-2 10 234244862 ns/op
BenchmarkSearch_Tolerance32ForLargeTree-2 3 722881937 ns/op
BenchmarkLinearSearchForLargeSet-2 10 281977270 ns/op
If the tolerance is small enough, BK-tree is much faster than naive linear search.
Example
see _example/ direcotry.
Install
$ go get github.com/agatan/bktree
License
MIT
Related Skills
node-connect
346.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
346.8kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
107.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
