pub struct Graph { /* private fields */ }Expand description
Per-layer graph used while constructing an index.
Inspect a live index through crate::HnswIndex::graph or the index’s
read-only accessors. The graph stored on an index cannot be replaced, and
mutation methods here are crate-private so external callers cannot desync
adjacency from vectors.
Adjacency lists are directed. Insertion adds both directed edges atomically
(a reverse-edge failure undoes the forward write), then reverse links are
pruned on the neighbor only, so a dropped A → B edge can leave B → A
in place.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn edges(&self, level: u8, node_index: NodeIndex) -> &[NodeIndex] ⓘ
pub fn edges(&self, level: u8, node_index: NodeIndex) -> &[NodeIndex] ⓘ
Outgoing neighbors of node_index at level.
Empty when the node is missing or node.level < level. The slice is
sorted and unique. Adjacency is directed: reverse-link prune drops an
outgoing edge on one node and leaves the peer’s reverse edge in place,
so edges(level, a) containing b does not imply the reverse.
Sourcepub fn node_count(&self) -> NodeIndex
pub fn node_count(&self) -> NodeIndex
Sourcepub fn layer_count(&self) -> u8
pub fn layer_count(&self) -> u8
Number of allocated layers (highest assigned node level plus one).
0 on an empty graph.