pub struct MemoryGraph { /* private fields */ }Expand description
The core in-memory graph structure holding cognitive events and their relationships.
Implementations§
Source§impl MemoryGraph
impl MemoryGraph
Sourcepub fn from_parts(
nodes: Vec<CognitiveEvent>,
edges: Vec<Edge>,
dimension: usize,
) -> AmemResult<Self>
pub fn from_parts( nodes: Vec<CognitiveEvent>, edges: Vec<Edge>, dimension: usize, ) -> AmemResult<Self>
Create from pre-existing data (used by reader).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges.
Sourcepub fn get_node(&self, id: u64) -> Option<&CognitiveEvent>
pub fn get_node(&self, id: u64) -> Option<&CognitiveEvent>
Get a node by ID (immutable).
Sourcepub fn get_node_mut(&mut self, id: u64) -> Option<&mut CognitiveEvent>
pub fn get_node_mut(&mut self, id: u64) -> Option<&mut CognitiveEvent>
Get a node by ID (mutable).
Sourcepub fn ensure_adjacency(&mut self)
pub fn ensure_adjacency(&mut self)
Ensure adjacency indexes are up to date. No-op in the current implementation (adjacency is always up to date).
Sourcepub fn edges_from(&self, source_id: u64) -> &[Edge]
pub fn edges_from(&self, source_id: u64) -> &[Edge]
Get all edges from a source node.
Sourcepub fn nodes(&self) -> &[CognitiveEvent]
pub fn nodes(&self) -> &[CognitiveEvent]
Get all nodes (immutable slice).
Sourcepub fn add_node(&mut self, event: CognitiveEvent) -> AmemResult<u64>
pub fn add_node(&mut self, event: CognitiveEvent) -> AmemResult<u64>
Add a node, returns the assigned ID.
Sourcepub fn add_edge(&mut self, edge: Edge) -> AmemResult<()>
pub fn add_edge(&mut self, edge: Edge) -> AmemResult<()>
Add an edge between two existing nodes.
Sourcepub fn remove_node(&mut self, id: u64) -> AmemResult<CognitiveEvent>
pub fn remove_node(&mut self, id: u64) -> AmemResult<CognitiveEvent>
Remove a node and all its edges.
Sourcepub fn remove_edge(
&mut self,
source_id: u64,
target_id: u64,
edge_type: EdgeType,
) -> AmemResult<()>
pub fn remove_edge( &mut self, source_id: u64, target_id: u64, edge_type: EdgeType, ) -> AmemResult<()>
Remove a specific edge.
Sourcepub fn type_index(&self) -> &TypeIndex
pub fn type_index(&self) -> &TypeIndex
Get the type index.
Sourcepub fn temporal_index(&self) -> &TemporalIndex
pub fn temporal_index(&self) -> &TemporalIndex
Get the temporal index.
Sourcepub fn session_index(&self) -> &SessionIndex
pub fn session_index(&self) -> &SessionIndex
Get the session index.
Sourcepub fn cluster_map(&self) -> &ClusterMap
pub fn cluster_map(&self) -> &ClusterMap
Get the cluster map.
Sourcepub fn cluster_map_mut(&mut self) -> &mut ClusterMap
pub fn cluster_map_mut(&mut self) -> &mut ClusterMap
Get a mutable reference to the cluster map.
Auto Trait Implementations§
impl Freeze for MemoryGraph
impl RefUnwindSafe for MemoryGraph
impl Send for MemoryGraph
impl Sync for MemoryGraph
impl Unpin for MemoryGraph
impl UnsafeUnpin for MemoryGraph
impl UnwindSafe for MemoryGraph
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