knn HNSW

new HNSW(metricopt, heuristicopt, mopt, efopt, m0opt, mLopt, seedopt)

Hierarchical navigable small world graph. Efficient and robust approximate nearest neighbor search.

Parameters:
NameTypeAttributesDefaultDescription
metricfunction<optional>
euclidean

metric to use: (a, b) => distance.

heuristicBoolean<optional>
true

use heuristics or naive selection.

mNumber<optional>
5

max number of connections.

efNumber<optional>
200

size of candidate list.

m0Number<optional>
2 * m

max number of connections for ground layer.

mLNumber<optional>
1 / Math.log2(m)

normalization factor for level generation.

seedNumber<optional>
1987

seed for random number generator.

Methods

add(elements) → {HNSW}

Parameters:
NameTypeDescription
elementsArray.<*>

new elements.

Returns:
Type: 
HNSW
Parameters:
NameTypeDefaultDescription
q*

query element.

K*

number of nearest neighbors to return.

ef*1

size of the dynamic cnadidate list.

Returns:

K nearest elements to q.

Type: 
Array

(generator) search_iter(q, K, ef)

Iterator for searching the HNSW graphs

Parameters:
NameTypeDefaultDescription
q*

query element.

K*

number of nearest neighbors to return.

ef*1

size of the dynamic cnadidate list.