pub struct HnswNode {
pub entity_id: EntityId,
pub embedding: Embedding,
pub max_layer: usize,
pub connections: Vec<Vec<EntityId>>,
}Expand description
A node in the HNSW graph.
Fields§
§entity_id: EntityIdThe entity ID this node represents.
embedding: EmbeddingThe embedding vector.
max_layer: usizeThe maximum layer this node appears in.
connections: Vec<Vec<EntityId>>Connections to other nodes, indexed by layer.
connections[layer] = list of neighbor entity IDs
Implementations§
Source§impl HnswNode
impl HnswNode
Sourcepub fn new(entity_id: EntityId, embedding: Embedding, max_layer: usize) -> Self
pub fn new(entity_id: EntityId, embedding: Embedding, max_layer: usize) -> Self
Create a new HNSW node.
Sourcepub fn connections_at(&self, layer: usize) -> &[EntityId]
pub fn connections_at(&self, layer: usize) -> &[EntityId]
Get the connections at a specific layer.
Sourcepub fn add_connection(&mut self, layer: usize, neighbor: EntityId)
pub fn add_connection(&mut self, layer: usize, neighbor: EntityId)
Add a connection at a specific layer.
Sourcepub fn remove_connection(&mut self, layer: usize, neighbor: EntityId)
pub fn remove_connection(&mut self, layer: usize, neighbor: EntityId)
Remove a connection at a specific layer.
Sourcepub fn set_connections(&mut self, layer: usize, neighbors: Vec<EntityId>)
pub fn set_connections(&mut self, layer: usize, neighbors: Vec<EntityId>)
Set the connections at a specific layer, replacing existing ones.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HnswNode
impl RefUnwindSafe for HnswNode
impl Send for HnswNode
impl Sync for HnswNode
impl Unpin for HnswNode
impl UnwindSafe for HnswNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more