nodedb_vector/hnsw/graph/mod.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! HNSW graph structure — nodes, parameters, core index operations.
4//!
5//! Production implementation per Malkov & Yashunin (2018).
6//! FP32 construction for structural integrity; heuristic neighbor selection.
7
8pub mod index;
9pub mod types;
10
11/// Initial arena capacity used when constructing a new [`index::HnswIndex`].
12///
13/// Sized to cover `ef_construction = 200` (the default) without needing a
14/// reallocation on the first insert or search.
15pub(crate) const ARENA_INITIAL_CAPACITY: usize = 256;
16
17/// Hard cap on the layer assigned to any node during insertion.
18/// Standard HNSW practice — prevents pathological RNG draws from inflating
19/// `max_layer` and slowing every subsequent search.
20pub const MAX_LAYER_CAP: usize = 16;
21
22pub use index::HnswIndex;
23pub use nodedb_types::hnsw::HnswParams;
24pub use types::{Candidate, Node, NodeStorage, SearchResult, Xorshift64};