Internal functions
Internal Types
HNSW.Neighbor — Type
Neighbor{T, F}(idx::T, dist::F)Simple struct for storing a neighbor index along with its distance to some query element.
sourceHNSW.NeighborSet — Type
NeighborSet(n::Neighbor)An ordered List of Neighbor, sorted by the dist field. Elements can be added by calling
insert!(ns::NeighborsSet, n::Neighbor)and retrieved with
nearest(ns::NeighborSet) → Neighbor
nearest(ns::NeighborSet, k) → k nearest Neighbors
furthest(ns::NeighborSet) → Neighbor
pop_nearest!(ns::NeighborSet) → Neighbor
pop_furthest!(ns::NeighborSet) → NeighborsourceOther Internal Functions
HNSW.LayeredGraph — Method
LayeredGraph{T}(num_elements, M, M0, m_L)A multi-layer directed graph with num_elements nodes and edges of type T. The bottom layer contains all points and each upper layer contains a subset of nodes of the one below. M0 is the maximum number of edges in the bottom layer. M is the maximum number of edges in all other layers.
m_L is used for random level generation. ( See get_random_level )
HNSW.VisitedList — Method
VisitedList(num_elements)List with num_elements entries to keep track of wether they have been visited or not. Check status with isvisited(vl::VisitedList, idx) → Bool
and visit with visit!(vl::VisitedList, idx)
To reset the list, call 'reset!(vl)'.
sourceHNSW.VisitedListPool — Method
VisitedListPool(num_lists, num_elements)A thread-stable container for multiple VisitedLists initialized with num_lists lists with each num_elements entries.
To retrieve a list, call get_list(vlp::VisitedListPool), and to release ist, call release_list(vlp, vl::VisitedList).
HNSW.get_random_level — Method
get_random_level(lg)Generate a random layer level for a new node using exponential decay. Uses the normalization factor m_L to control the probability distribution.
HNSW.insert_point! — Function
insert_point!(hnsw, q, l = get_random_level(hnsw.lgraph))Insert index query referring to data point data[q] into the graph.
HNSW.neighbors — Method
neighbors(lg::LayeredGraph, level, q::Integer)Return an Iterator over all links currently assigned.
source