ArborGraph

Struct ArborGraph 

Source
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

Source

pub fn new() -> Self

Creates a new empty graph.

Source

pub fn add_node(&mut self, node: CodeNode) -> NodeIndex

Adds a code node to the graph.

Returns the node’s index for adding edges later.

Source

pub fn add_edge(&mut self, from: NodeIndex, to: NodeIndex, edge: Edge)

Adds an edge between two nodes.

Source

pub fn get_by_id(&self, id: &str) -> Option<&CodeNode>

Gets a node by its string ID.

Source

pub fn get(&self, index: NodeIndex) -> Option<&CodeNode>

Gets a node by its graph index.

Source

pub fn find_by_name(&self, name: &str) -> Vec<&CodeNode>

Finds all nodes with a given name.

Source

pub fn find_by_file(&self, file: &str) -> Vec<&CodeNode>

Finds all nodes in a file.

Source

pub fn search(&self, query: &str) -> Vec<&CodeNode>

Searches for nodes whose name contains the query.

Source

pub fn get_callers(&self, index: NodeIndex) -> Vec<&CodeNode>

Gets nodes that call the given node.

Source

pub fn get_callees(&self, index: NodeIndex) -> Vec<&CodeNode>

Gets nodes that this node calls.

Source

pub fn get_dependents( &self, index: NodeIndex, max_depth: usize, ) -> Vec<(NodeIndex, usize)>

Gets all nodes that depend on the given node (directly or transitively).

Source

pub fn remove_file(&mut self, file: &str)

Removes all nodes from a file. Used for incremental updates.

Source

pub fn centrality(&self, index: NodeIndex) -> f64

Gets the centrality score for a node.

Source

pub fn set_centrality(&mut self, scores: HashMap<NodeIndex, f64>)

Sets centrality scores (called after computation).

Source

pub fn node_count(&self) -> usize

Returns the number of nodes.

Source

pub fn edge_count(&self) -> usize

Returns the number of edges.

Source

pub fn nodes(&self) -> impl Iterator<Item = &CodeNode>

Iterates over all nodes.

Source

pub fn edges(&self) -> impl Iterator<Item = &Edge>

Iterates over all edges.

Source

pub fn export_edges(&self) -> Vec<GraphEdge>

Returns all edges with source and target IDs for export.

Source

pub fn node_indexes(&self) -> impl Iterator<Item = NodeIndex> + '_

Iterates over all node indexes.

Source

pub fn get_index(&self, id: &str) -> Option<NodeIndex>

Gets the node index for a string ID.

Source§

impl ArborGraph

Source

pub fn stats(&self) -> GraphStats

Returns graph statistics.

Trait Implementations§

Source§

impl Debug for ArborGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArborGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.