pub struct MemoryGraph { /* private fields */ }Expand description
A memory link graph for computing PageRank-style importance.
Nodes are memory entry IDs (mapped to u64 indices internally). Edges represent co-access relationships.
Implementations§
Source§impl MemoryGraph
impl MemoryGraph
Sourcepub fn add_edge(&mut self, from: u64, to: u64)
pub fn add_edge(&mut self, from: u64, to: u64)
Add a directed edge from from to to.
If the edge already exists, this is a no-op.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the graph.
Sourcepub fn pagerank(
&self,
damping: f64,
iterations: usize,
initial_scores: Option<&HashMap<u64, f64>>,
) -> HashMap<u64, f64>
pub fn pagerank( &self, damping: f64, iterations: usize, initial_scores: Option<&HashMap<u64, f64>>, ) -> HashMap<u64, f64>
Compute PageRank scores for all nodes.
Uses the standard iterative algorithm with damping factor.
§Arguments
damping— Damping factor (typically 0.85).iterations— Number of iterations (typically 20-50).initial_scores— Optional initial scores (e.g., base importance). If provided, the initial PageRank is seeded with these values.
§Returns
A map of node ID -> PageRank score.
Sourcepub fn from_co_access(sessions: &[Vec<u64>]) -> Self
pub fn from_co_access(sessions: &[Vec<u64>]) -> Self
Compute co-access graph from session access patterns.
Given a list of sessions where each session contains a list of memory IDs that were accessed together, build a graph where co-accessed memories are linked.
Trait Implementations§
Source§impl Clone for MemoryGraph
impl Clone for MemoryGraph
Source§fn clone(&self) -> MemoryGraph
fn clone(&self) -> MemoryGraph
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 MemoryGraph
impl Debug for MemoryGraph
Source§impl Default for MemoryGraph
impl Default for MemoryGraph
Source§fn default() -> MemoryGraph
fn default() -> MemoryGraph
Returns the “default value” for a type. Read more
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