pub struct GraphTree { /* private fields */ }Expand description
Graph tree structure for hierarchical memory organization
Implementations§
Source§impl GraphTree
impl GraphTree
Sourcepub fn add_memory(
&mut self,
memory_id: NodeId,
category: &str,
memory_lane_type: Option<&str>,
priority: Option<u8>,
)
pub fn add_memory( &mut self, memory_id: NodeId, category: &str, memory_lane_type: Option<&str>, priority: Option<u8>, )
Add a memory node to the tree
Sourcepub fn remove_memory(&mut self, memory_id: NodeId) -> bool
pub fn remove_memory(&mut self, memory_id: NodeId) -> bool
Remove a memory node from the tree
Sourcepub fn get_memories_by_category(&self, category: &str) -> Vec<NodeId> ⓘ
pub fn get_memories_by_category(&self, category: &str) -> Vec<NodeId> ⓘ
Get all memory IDs in a category
Sourcepub fn get_memories_by_lane_type(&self, lane_type: &str) -> Vec<NodeId> ⓘ
pub fn get_memories_by_lane_type(&self, lane_type: &str) -> Vec<NodeId> ⓘ
Get all memory IDs with a specific lane type
Sourcepub fn get_ancestors(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
pub fn get_ancestors(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
Get ancestors of a node (path to root)
Sourcepub fn get_descendants(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
pub fn get_descendants(&self, node_id: NodeId) -> Vec<NodeId> ⓘ
Get descendants of a node (BFS)
Sourcepub fn calculate_boosted_score(
&self,
memory_id: NodeId,
base_similarity: f32,
) -> f32
pub fn calculate_boosted_score( &self, memory_id: NodeId, base_similarity: f32, ) -> f32
Calculate boosted relevance score based on tree structure
Sourcepub fn traverse_bfs(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
pub fn traverse_bfs(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
Breadth-first traversal from a starting node
Sourcepub fn traverse_dfs_preorder(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
pub fn traverse_dfs_preorder(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
Depth-first traversal (pre-order) from a starting node
Sourcepub fn traverse_dfs_postorder(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
pub fn traverse_dfs_postorder(&self, start_id: NodeId) -> Vec<NodeId> ⓘ
Depth-first traversal (post-order) from a starting node
Sourcepub fn get_nodes_at_depth(&self, depth: u32) -> Vec<NodeId> ⓘ
pub fn get_nodes_at_depth(&self, depth: u32) -> Vec<NodeId> ⓘ
Get nodes at a specific depth level
Sourcepub fn get_all_leaves(&self) -> Vec<NodeId> ⓘ
pub fn get_all_leaves(&self) -> Vec<NodeId> ⓘ
Get all leaf nodes (memory entries)
Sourcepub fn find_lca(&self, node_a: NodeId, node_b: NodeId) -> Option<NodeId>
pub fn find_lca(&self, node_a: NodeId, node_b: NodeId) -> Option<NodeId>
Find lowest common ancestor of two nodes
Sourcepub fn distance(&self, node_a: NodeId, node_b: NodeId) -> Option<u32>
pub fn distance(&self, node_a: NodeId, node_b: NodeId) -> Option<u32>
Calculate the distance between two nodes
Sourcepub fn subtree_size(&self, node_id: NodeId) -> usize
pub fn subtree_size(&self, node_id: NodeId) -> usize
Get subtree size for a node (including itself)
Sourcepub fn prune_below_depth(&mut self, max_depth: u32) -> Vec<NodeId> ⓘ
pub fn prune_below_depth(&mut self, max_depth: u32) -> Vec<NodeId> ⓘ
Prune nodes below a certain depth
Sourcepub fn find_matching<F>(&self, predicate: F) -> Vec<NodeId> ⓘ
pub fn find_matching<F>(&self, predicate: F) -> Vec<NodeId> ⓘ
Find all nodes matching a predicate
Sourcepub fn rebalance_weights(&mut self)
pub fn rebalance_weights(&mut self)
Rebalance weights in the tree