pub struct Node { /* private fields */ }Expand description
Node is a single node in the HNSW graph, aka your vector embedding
Implementations§
Source§impl Node
impl Node
pub fn new(id: u32, value: Vector, max_level: usize) -> Self
Sourcepub fn connections(&self, level: usize) -> Vec<u32>
pub fn connections(&self, level: usize) -> Vec<u32>
get the connections for a given level
pub fn connections_len(&self) -> usize
pub fn add_connection_level(&mut self)
Sourcepub fn distance(&self, other: &Vector, distance_metric: &DistanceMetric) -> f32
pub fn distance(&self, other: &Vector, distance_metric: &DistanceMetric) -> f32
distance calculates the distance between this node and another vector
Sourcepub fn connect(&mut self, other: &mut Node, level: usize)
pub fn connect(&mut self, other: &mut Node, level: usize)
connect connects this node to another node at a given level
Sourcepub fn disconnect(&mut self, other: &mut Node, level: usize)
pub fn disconnect(&mut self, other: &mut Node, level: usize)
disconnect disconnects this node from another node at a given level
Sourcepub fn remove_connections(&mut self, ids: &[u32], level: usize)
pub fn remove_connections(&mut self, ids: &[u32], level: usize)
remove_connections removes the connections of this node at a given level
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
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