All internal functions
HNSW.HierarchicalNSW
— TypeHierarchicalNSW{T,F,V,M}
HNSW.LayeredGraph
— MethodLayeredGraph{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 'getrandomlevel' )
HNSW.Neighbor
— TypeNeighbor{T, F}(idx::T, dist::F)
Simple struct for storing a neighbor index along with its distance to some query element.
HNSW.NeighborSet
— TypeNeighborSet(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) → Neighbor
HNSW.VisitedList
— MethodVisitedList(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)'.
HNSW.VisitedListPool
— MethodVisitedListPool(num_lists, num_elements)
A thread-stable container for multiple VisitedList
s 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.add!
— Methodadd!(hnsw, newdata)
Add new data to the graph.
HNSW.add_to_graph!
— Methodadd_to_graph!(notify_func, hnsw, indices, multithreading=false)
Add i ∈ indices
referring to data[i]
into the graph.
notify_func(i)
provides an interface for a progress notification by current index.
Indices already added previously will be ignored.
HNSW.add_to_graph!
— Methodadd_to_graph!(hnsw, indices)
short form of add_to_graph!(notify_func, hnsw, indices)
HNSW.insert_point!
— Functioninsert_point!(hnsw, q, l = get_random_level(hnsw.lgraph))
Insert index query
referring to data point data[q]
into the graph.
HNSW.neighbors
— Methodneighbors(lg::LayeredGraph, level, q::Integer)
Return an Iterator over all links currently assigned.