pub struct InMemoryGraphStore { /* private fields */ }Expand description
In-memory graph store for similarity edges.
This implementation uses adjacency lists for efficient edge traversal and supports bidirectional lookups.
Implementations§
Source§impl InMemoryGraphStore
impl InMemoryGraphStore
Sourcepub fn node_ids(&self) -> Vec<EmbeddingId>
pub fn node_ids(&self) -> Vec<EmbeddingId>
Get all unique node IDs in the graph.
Sourcepub fn degree(&self, id: &EmbeddingId) -> usize
pub fn degree(&self, id: &EmbeddingId) -> usize
Get the degree (number of connections) for a node.
Sourcepub fn export(&self) -> GraphExport
pub fn export(&self) -> GraphExport
Export the graph for serialization.
Sourcepub fn import(&self, data: GraphExport) -> RepoResult<()>
pub fn import(&self, data: GraphExport) -> RepoResult<()>
Import a graph from serialized data.
Trait Implementations§
Source§impl Debug for InMemoryGraphStore
impl Debug for InMemoryGraphStore
Source§impl Default for InMemoryGraphStore
impl Default for InMemoryGraphStore
Source§impl GraphEdgeRepository for InMemoryGraphStore
impl GraphEdgeRepository for InMemoryGraphStore
Source§fn add_edge<'life0, 'async_trait>(
&'life0 self,
edge: SimilarityEdge,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_edge<'life0, 'async_trait>(
&'life0 self,
edge: SimilarityEdge,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add an edge between two embeddings.
Source§fn add_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
edges: &'life1 [SimilarityEdge],
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
edges: &'life1 [SimilarityEdge],
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add multiple edges in a batch.
Source§fn remove_edge<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 EmbeddingId,
to: &'life2 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_edge<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 EmbeddingId,
to: &'life2 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove an edge between two embeddings.
Source§fn get_edges_from<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_edges_from<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all edges from a given embedding.
Source§fn get_edges_to<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_edges_to<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all edges to a given embedding.
Source§fn get_edges_by_type<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
edge_type: EdgeType,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_edges_by_type<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
edge_type: EdgeType,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get edges of a specific type from an embedding.
Source§fn get_strong_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
min_similarity: f32,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_strong_edges<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
min_similarity: f32,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<SimilarityEdge>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find edges with similarity above a threshold.
Source§fn edge_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn edge_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the number of edges in the graph.
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all edges.
Source§fn remove_edges_for<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_edges_for<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove all edges connected to an embedding.
Source§impl GraphTraversal for InMemoryGraphStore
impl GraphTraversal for InMemoryGraphStore
Source§fn shortest_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 EmbeddingId,
to: &'life2 EmbeddingId,
max_depth: usize,
) -> Pin<Box<dyn Future<Output = RepoResult<Option<Vec<EmbeddingId>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn shortest_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 EmbeddingId,
to: &'life2 EmbeddingId,
max_depth: usize,
) -> Pin<Box<dyn Future<Output = RepoResult<Option<Vec<EmbeddingId>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Find the shortest path between two embeddings.
Source§fn neighbors_within_hops<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
hops: usize,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<(EmbeddingId, usize)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn neighbors_within_hops<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 EmbeddingId,
hops: usize,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<(EmbeddingId, usize)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find all embeddings within n hops of a given embedding.
Source§fn connected_components<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<Vec<EmbeddingId>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connected_components<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<Vec<EmbeddingId>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Find connected components in the graph.
Source§fn centrality_scores<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<(EmbeddingId, f32)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn centrality_scores<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RepoResult<Vec<(EmbeddingId, f32)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Calculate PageRank-style centrality for embeddings.
Auto Trait Implementations§
impl !Freeze for InMemoryGraphStore
impl !RefUnwindSafe for InMemoryGraphStore
impl Forget for InMemoryGraphStore
impl Send for InMemoryGraphStore
impl Sync for InMemoryGraphStore
impl Unpin for InMemoryGraphStore
impl UnsafeUnpin for InMemoryGraphStore
impl UnwindSafe for InMemoryGraphStore
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> 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 more