Build a heap of candidate neighbors for nearest neighbor descent.
Build a heap of candidate neighbors for nearest neighbor descent. For each vertex the candidate neighbors are any current neighbors, and any vertices that have the vertex as one of their nearest neighbors.
The total number of vertices in the graph.
The number of neighbor edges per node in the current graph.
The maximum number of new candidate neighbors.
The internal state of the rng
candidateNeighbors: A heap with an array of (randomly sorted) candidate neighbors for each vertex in the graph.
Given an array of heaps (of indices and weights), unpack the heap out to give and array of sorted lists of indices and weights by increasing weight.
Given an array of heaps (of indices and weights), unpack the heap out to give and array of sorted lists of indices and weights by increasing weight. This is effectively just the second half of heap sort (the first half not being required since we already have the data in a heap).
The indices and weights sorted by increasing weight.
Build a heap of candidate neighbors for nearest neighbor descent.
Build a heap of candidate neighbors for nearest neighbor descent. For each vertex the candidate neighbors are any current neighbors, and any vertices that have the vertex as one of their nearest neighbors.
The total number of vertices in the graph.
The number of neighbor edges per node in the current graph.
The maximum number of new candidate neighbors.
The internal state of the rng
A heap with an array of (randomly sorted) candidate neighbors for each vertex in the graph.
Search the heap for the smallest element that is still flagged.
Search the heap for the smallest element that is still flagged.
Which of the heaps to search
The index of the smallest flagged element
of the th heap, or -1 if no flagged
elements remain in the heap.row