Skip to content

yzbmz5913/hnsw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hnsw

Hierarchical Navigable Small World, a kind of approximate nearest neighbors algorithm.

func main() {
	h := hnsw.NewHNSW(100, 8, hnsw.NewL2Space(2))
	var points []*hnsw.Point
	for i := 0; i < 1000; i++ {
		h.Insert(hnsw.NewPoint([]float64{rand.Float64(), rand.Float64()}))
	}
	target := hnsw.NewPoint([]float64{0.5, 0.5})
	knn := h.SearchKNN(target, 20)
	for i, p := range knn {
		fmt.Printf("candidate %d: %v\n", i, p)
	}
}

About

Hierarchical Navigable Small World

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages