pub struct VamanaGraph { /* private fields */ }Expand description
Vamana graph structure
Implementations§
Source§impl VamanaGraph
impl VamanaGraph
Sourcepub fn new(
max_degree: usize,
pruning_strategy: PruningStrategy,
alpha: f32,
) -> Self
pub fn new( max_degree: usize, pruning_strategy: PruningStrategy, alpha: f32, ) -> Self
Create a new empty Vamana graph
Sourcepub fn max_degree(&self) -> usize
pub fn max_degree(&self) -> usize
Get maximum degree
Sourcepub fn entry_points(&self) -> &[NodeId] ⓘ
pub fn entry_points(&self) -> &[NodeId] ⓘ
Get entry points
Sourcepub fn set_entry_points(&mut self, entry_points: Vec<NodeId>)
pub fn set_entry_points(&mut self, entry_points: Vec<NodeId>)
Set entry points
Sourcepub fn add_entry_point(&mut self, node_id: NodeId) -> DiskAnnResult<()>
pub fn add_entry_point(&mut self, node_id: NodeId) -> DiskAnnResult<()>
Add entry point
Sourcepub fn get_node(&self, node_id: NodeId) -> Option<&VamanaNode>
pub fn get_node(&self, node_id: NodeId) -> Option<&VamanaNode>
Get node by ID
Sourcepub fn get_node_mut(&mut self, node_id: NodeId) -> Option<&mut VamanaNode>
pub fn get_node_mut(&mut self, node_id: NodeId) -> Option<&mut VamanaNode>
Get mutable node by ID
Sourcepub fn get_node_id(&self, vector_id: &VectorId) -> Option<NodeId>
pub fn get_node_id(&self, vector_id: &VectorId) -> Option<NodeId>
Get node ID by vector ID
Sourcepub fn add_node(&mut self, vector_id: VectorId) -> DiskAnnResult<NodeId>
pub fn add_node(&mut self, vector_id: VectorId) -> DiskAnnResult<NodeId>
Add a new node to the graph
Sourcepub fn remove_node(&mut self, node_id: NodeId) -> DiskAnnResult<()>
pub fn remove_node(&mut self, node_id: NodeId) -> DiskAnnResult<()>
Remove a node from the graph
Sourcepub fn add_edge(
&mut self,
source: NodeId,
target: NodeId,
) -> DiskAnnResult<bool>
pub fn add_edge( &mut self, source: NodeId, target: NodeId, ) -> DiskAnnResult<bool>
Add a directed edge from source to target
Sourcepub fn remove_edge(
&mut self,
source: NodeId,
target: NodeId,
) -> DiskAnnResult<bool>
pub fn remove_edge( &mut self, source: NodeId, target: NodeId, ) -> DiskAnnResult<bool>
Remove a directed edge from source to target
Sourcepub fn prune_neighbors<F>(
&mut self,
node_id: NodeId,
candidates: &[(NodeId, f32)],
distance_fn: &F,
) -> DiskAnnResult<()>
pub fn prune_neighbors<F>( &mut self, node_id: NodeId, candidates: &[(NodeId, f32)], distance_fn: &F, ) -> DiskAnnResult<()>
Prune neighbors of a node using the configured strategy
§Arguments
node_id- Node whose neighbors to prunecandidates- Candidate neighbors with their distancesdistance_fn- Function to compute distance between node IDs
Sourcepub fn get_neighbors(&self, node_id: NodeId) -> Option<&[NodeId]>
pub fn get_neighbors(&self, node_id: NodeId) -> Option<&[NodeId]>
Get all neighbors of a node
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Get graph statistics
Sourcepub fn validate(&self) -> DiskAnnResult<()>
pub fn validate(&self) -> DiskAnnResult<()>
Validate graph integrity
Trait Implementations§
Source§impl Clone for VamanaGraph
impl Clone for VamanaGraph
Source§fn clone(&self) -> VamanaGraph
fn clone(&self) -> VamanaGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VamanaGraph
impl Debug for VamanaGraph
Source§impl Decode for VamanaGraph
impl Decode for VamanaGraph
Source§impl Default for VamanaGraph
impl Default for VamanaGraph
Source§impl<'de> Deserialize<'de> for VamanaGraph
impl<'de> Deserialize<'de> for VamanaGraph
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
Source§impl Encode for VamanaGraph
impl Encode for VamanaGraph
Auto Trait Implementations§
impl Freeze for VamanaGraph
impl RefUnwindSafe for VamanaGraph
impl Send for VamanaGraph
impl Sync for VamanaGraph
impl Unpin for VamanaGraph
impl UnwindSafe for VamanaGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.