Package io.github.jbellis.jvector.graph
Class NeighborArray
java.lang.Object
io.github.jbellis.jvector.graph.NeighborArray
NeighborArray encodes the neighbors of a node and their mutual scores in the graph as a pair
of growable arrays. Nodes are arranged in the sorted order of their scores in descending order,
i.e. the most-similar neighbors are first.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInOrder(int newNode, float newScore) Add a new node to the NeighborArray.voidclear()protected final intdescSortFindRightMostInsertionPoint(float newScore) protected final voidvoidinsertSorted(int newNode, float newScore) Add a new node to the NeighborArray into a correct sort position according to its score.int[]node()Direct access to the internal list of node ids; provided for efficient writing of the graphvoidremoveIndex(int idx) voidfloat[]score()intsize()toString()
-
Field Details
-
size
protected int size
-
-
Constructor Details
-
NeighborArray
public NeighborArray(int maxSize)
-
-
Method Details
-
addInOrder
public void addInOrder(int newNode, float newScore) Add a new node to the NeighborArray. The new node must be worse than all previously stored nodes. -
insertSorted
public void insertSorted(int newNode, float newScore) Add a new node to the NeighborArray into a correct sort position according to its score. -
growArrays
protected final void growArrays() -
size
public int size() -
node
public int[] node()Direct access to the internal list of node ids; provided for efficient writing of the graph -
score
public float[] score() -
clear
public void clear() -
removeLast
public void removeLast() -
removeIndex
public void removeIndex(int idx) -
toString
-
descSortFindRightMostInsertionPoint
protected final int descSortFindRightMostInsertionPoint(float newScore)
-