pub struct CsrGraph { /* private fields */ }Expand description
Bidirectional graph with CSR (outgoing) and CSC (incoming) plus a delta log.
Implementations§
Source§impl CsrGraph
impl CsrGraph
Sourcepub fn remove_node(&mut self, id: MemoryId)
pub fn remove_node(&mut self, id: MemoryId)
Remove a node and all its edges.
Sourcepub fn add_edge(&mut self, edge: &MemoryEdge)
pub fn add_edge(&mut self, edge: &MemoryEdge)
Add an edge to the delta log.
Sourcepub fn remove_edge(&mut self, source: MemoryId, target: MemoryId)
pub fn remove_edge(&mut self, source: MemoryId, target: MemoryId)
Mark an edge for removal.
Sourcepub fn outgoing(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>
pub fn outgoing(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>
Get all outgoing edges from a node (CSR + delta, minus removed).
Sourcepub fn outgoing_valid_at(
&self,
id: MemoryId,
at: Timestamp,
) -> Vec<(MemoryId, StoredEdge)>
pub fn outgoing_valid_at( &self, id: MemoryId, at: Timestamp, ) -> Vec<(MemoryId, StoredEdge)>
Get outgoing edges that are temporally valid at the given timestamp.
Sourcepub fn incoming(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>
pub fn incoming(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>
Get all incoming edges to a node (CSC + delta, minus removed).
Sourcepub fn incoming_valid_at(
&self,
id: MemoryId,
at: Timestamp,
) -> Vec<(MemoryId, StoredEdge)>
pub fn incoming_valid_at( &self, id: MemoryId, at: Timestamp, ) -> Vec<(MemoryId, StoredEdge)>
Get incoming edges that are temporally valid at the given timestamp.
Sourcepub fn contains_node(&self, id: MemoryId) -> bool
pub fn contains_node(&self, id: MemoryId) -> bool
Check if a node exists in the graph.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of registered nodes.
Sourcepub fn compact(&mut self)
pub fn compact(&mut self)
Merge all delta edges and removals into the compressed CSR/CSC storage.
Sourcepub fn save(&self, path: &Path) -> MenteResult<()>
pub fn save(&self, path: &Path) -> MenteResult<()>
Save the graph to a JSON file.
Sourcepub fn load(path: &Path) -> MenteResult<Self>
pub fn load(path: &Path) -> MenteResult<Self>
Load the graph from a JSON file.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CsrGraph
impl<'de> Deserialize<'de> for CsrGraph
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 CsrGraph
impl RefUnwindSafe for CsrGraph
impl Send for CsrGraph
impl Sync for CsrGraph
impl Unpin for CsrGraph
impl UnsafeUnpin for CsrGraph
impl UnwindSafe for CsrGraph
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