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) -> NodeId

Adds a code node to the graph.

Returns the node’s index for adding edges later.

Source

pub fn add_edge(&mut self, from: NodeId, to: NodeId, 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: NodeId) -> 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: NodeId) -> Vec<&CodeNode>

Gets nodes that call the given node.

Source

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

Gets nodes that this node calls.

Source

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).

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: NodeId) -> f64

Gets the centrality score for a node.

Source

pub fn set_centrality(&mut self, scores: HashMap<NodeId, 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 = NodeId> + '_

Iterates over all node indexes.

Source

pub fn find_path(&self, from: NodeId, to: NodeId) -> Option<Vec<&CodeNode>>

Finds the shortest path between two nodes.

Source

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

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
Source§

impl<'de> Deserialize<'de> for ArborGraph

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ArborGraph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,