pub struct ArborGraph { /* private fields */ }Expand description
The code relationship graph.
This is the heart of Arbor. It stores all code entities as nodes and their relationships as edges, with indexes for fast access.
Implementations§
Source§impl ArborGraph
impl ArborGraph
Sourcepub fn add_node(&mut self, node: CodeNode) -> NodeId
pub fn add_node(&mut self, node: CodeNode) -> NodeId
Adds a code node to the graph.
Returns the node’s index for adding edges later.
Sourcepub fn add_edge(&mut self, from: NodeId, to: NodeId, edge: Edge)
pub fn add_edge(&mut self, from: NodeId, to: NodeId, edge: Edge)
Adds an edge between two nodes.
Sourcepub fn find_by_name(&self, name: &str) -> Vec<&CodeNode>
pub fn find_by_name(&self, name: &str) -> Vec<&CodeNode>
Finds all nodes with a given name.
Sourcepub fn find_by_file(&self, file: &str) -> Vec<&CodeNode>
pub fn find_by_file(&self, file: &str) -> Vec<&CodeNode>
Finds all nodes in a file.
Sourcepub fn search(&self, query: &str) -> Vec<&CodeNode>
pub fn search(&self, query: &str) -> Vec<&CodeNode>
Searches for nodes whose name contains the query.
Sourcepub fn get_callers(&self, index: NodeId) -> Vec<&CodeNode>
pub fn get_callers(&self, index: NodeId) -> Vec<&CodeNode>
Gets nodes that call the given node.
Sourcepub fn get_callees(&self, index: NodeId) -> Vec<&CodeNode>
pub fn get_callees(&self, index: NodeId) -> Vec<&CodeNode>
Gets nodes that this node calls.
Sourcepub fn get_dependents(
&self,
index: NodeId,
max_depth: usize,
) -> Vec<(NodeId, usize)>
pub fn get_dependents( &self, index: NodeId, max_depth: usize, ) -> Vec<(NodeId, usize)>
Gets all nodes that depend on the given node (directly or transitively).
Sourcepub fn remove_file(&mut self, file: &str)
pub fn remove_file(&mut self, file: &str)
Removes all nodes from a file. Used for incremental updates.
Sourcepub fn centrality(&self, index: NodeId) -> f64
pub fn centrality(&self, index: NodeId) -> f64
Gets the centrality score for a node.
Sourcepub fn set_centrality(&mut self, scores: HashMap<NodeId, f64>)
pub fn set_centrality(&mut self, scores: HashMap<NodeId, f64>)
Sets centrality scores (called after computation).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Returns the number of edges.
Sourcepub fn export_edges(&self) -> Vec<GraphEdge>
pub fn export_edges(&self) -> Vec<GraphEdge>
Returns all edges with source and target IDs for export.
Sourcepub fn node_indexes(&self) -> impl Iterator<Item = NodeId> + '_
pub fn node_indexes(&self) -> impl Iterator<Item = NodeId> + '_
Iterates over all node indexes.