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 strengthen_edge(
&mut self,
source: MemoryId,
target: MemoryId,
delta: f32,
)
pub fn strengthen_edge( &mut self, source: MemoryId, target: MemoryId, delta: f32, )
Strengthen an edge by incrementing its weight (Hebbian learning). Adds a delta edge with the new weight; compaction will merge it.
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.