jelmerk / hnswlib

Java library for approximate nearest neighbors search using Hierarchical Navigable Small World graphs
Apache License 2.0
260 stars 56 forks source link

Cannot understand the definition of curdist in getNeighborsByHeuristic2? #42

Closed tonight-is-you closed 2 years ago

tonight-is-you commented 3 years ago

HnswIndex.java > getNeighborsByHeuristic2:

for (NodeIdAndDistance<TDistance> secondPair : returnList) {
                TDistance curdist = distanceFunction.distance(
                        nodes.get(secondPair.nodeId).item.vector(),
                        nodes.get(currentPair.nodeId).item.vector()
                );

                if (lt(curdist, distToQuery)) {
                    good = false;
                    break;
                }
            }

according to HNSW's paper Algorithm 4 i think,curdist = distance(q, every element in returnList),not curdist = distance(e, every element in returnList),the definition of q and e is same as Algorithm 4, am i right?