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

init level connections under the control of maxM0 and maxM #54

Open gfhe opened 1 year ago

gfhe commented 1 year ago

At line 215 of HnswIndex.java, randomLevel==0 may not meet expectations, which will reault in maxM0 not working.

        for (int level = 0; level <= randomLevel; level++) {
            int levelM = level == 0 ? maxM0 : maxM;
            connections[level] = new IntArrayList(levelM);
        }
lvca commented 1 year ago

@gfhe I think it makes sense. WDYT @jelmerk?