DependencyGraph

Struct DependencyGraph 

Source
pub struct DependencyGraph { /* private fields */ }
Expand description

Efficient dependency graph representation optimized for PageRank computation Uses integer-based internal representation for massive performance improvements

Implementations§

Source§

impl DependencyGraph

Graph construction and manipulation operations

Source

pub fn new() -> DependencyGraph

Create a new empty dependency graph

Source

pub fn with_capacity(capacity: usize) -> DependencyGraph

Create with initial capacity hint for performance optimization

Source

pub fn add_node(&mut self, node_id: String) -> Result<usize, ScribeError>

Add a node to the graph (can exist without edges)

Source

pub fn add_node_with_metadata( &mut self, node_id: String, metadata: NodeMetadata, ) -> Result<usize, ScribeError>

Add a node with metadata

Source

pub fn add_edge( &mut self, from_node: String, to_node: String, ) -> Result<(), ScribeError>

Add an import edge: from_file imports to_file

Source

pub fn add_edges( &mut self, edges: &[(String, String)], ) -> Result<(), ScribeError>

Add multiple edges efficiently (batch operation)

Source

pub fn remove_node(&mut self, node_id: &String) -> Result<bool, ScribeError>

Remove a node and all its edges

Source

pub fn remove_edge( &mut self, from_node: &String, to_node: &String, ) -> Result<bool, ScribeError>

Remove an edge between two nodes

Source

pub fn contains_node(&self, node_id: &String) -> bool

Check if a node exists in the graph

Source

pub fn contains_edge(&self, from_node: &String, to_node: &String) -> bool

Check if an edge exists between two nodes

Source

pub fn node_count(&self) -> usize

Get the number of nodes in the graph

Source

pub fn edge_count(&self) -> usize

Get the total number of edges in the graph

Source

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

Get all nodes in the graph

Source

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

Get all edges in the graph as (from, to) pairs

Source§

impl DependencyGraph

Degree and neighbor query operations

Source

pub fn in_degree(&self, node_id: &String) -> usize

Get in-degree of a node (number of files that import this node)

Source

pub fn out_degree(&self, node_id: &String) -> usize

Get out-degree of a node (number of files this node imports)

Source

pub fn degree(&self, node_id: &String) -> usize

Get total degree of a node (in + out)

Source

pub fn outgoing_neighbors(&self, node_id: &String) -> Option<Vec<&String>>

Get nodes that this node imports (outgoing edges)

Source

pub fn incoming_neighbors(&self, node_id: &String) -> Option<Vec<&String>>

Get nodes that import this node (incoming edges) - important for PageRank

Source

pub fn all_neighbors(&self, node_id: &String) -> HashSet<&String>

Get both incoming and outgoing neighbors

Source

pub fn transitive_dependencies( &self, node_id: &String, max_depth: Option<usize>, ) -> HashSet<String>

Get all transitive dependencies of a node (files it depends on, transitively)

Performs BFS along outgoing edges to find all files this node imports, directly or indirectly, up to max_depth levels.

§Arguments
  • node_id - The starting node
  • max_depth - Maximum depth to traverse (None for unlimited)
§Returns

Set of all transitively reachable nodes via outgoing edges (dependencies)

Source

pub fn transitive_dependents( &self, node_id: &String, max_depth: Option<usize>, ) -> HashSet<String>

Get all transitive dependents of a node (files that depend on it, transitively)

Performs BFS along incoming edges to find all files that import this node, directly or indirectly, up to max_depth levels.

§Arguments
  • node_id - The starting node
  • max_depth - Maximum depth to traverse (None for unlimited)
§Returns

Set of all transitively reachable nodes via incoming edges (dependents)

Source

pub fn compute_closure( &self, seeds: &[String], direction: TraversalDirection, max_depth: Option<usize>, ) -> HashSet<String>

Compute the closure of a set of seed nodes

§Arguments
  • seeds - Starting set of nodes
  • direction - Which direction to traverse
  • max_depth - Maximum traversal depth (None for unlimited)
§Returns

Set containing all seeds plus all reachable nodes in the specified direction

Source

pub fn get_degree_info(&self, node_id: &String) -> Option<DegreeInfo>

Get degree information for a node

Source§

impl DependencyGraph

Node metadata and information queries

Source

pub fn node_metadata(&self, node_id: &String) -> Option<&NodeMetadata>

Get metadata for a node

Source

pub fn set_node_metadata( &mut self, node_id: String, metadata: NodeMetadata, ) -> Result<(), ScribeError>

Set metadata for a node

Source

pub fn entrypoint_nodes(&self) -> Vec<&String>

Get all entrypoint nodes

Source

pub fn test_nodes(&self) -> Vec<&String>

Get all test nodes

Source

pub fn nodes_by_language(&self, language: &str) -> Vec<&String>

Get nodes by language

Source§

impl DependencyGraph

Specialized operations for PageRank computation

Source

pub fn pagerank_iterator( &self, ) -> impl Iterator<Item = (&String, Option<Vec<&String>>)>

Get all nodes with their reverse edge neighbors (for PageRank iteration)

Source

pub fn dangling_nodes(&self) -> Vec<&String>

Get dangling nodes (nodes with no outgoing edges)

Source

pub fn estimate_scc_count(&self) -> usize

Get strongly connected components (simplified estimation for statistics)

Source

pub fn is_strongly_connected(&self) -> bool

Check if the graph is strongly connected (simplified check)

Source§

impl DependencyGraph

Concurrent graph operations for performance

Source

pub fn into_concurrent(self) -> ConcurrentDependencyGraph

Create a thread-safe concurrent graph for parallel operations

Trait Implementations§

Source§

impl Clone for DependencyGraph

Source§

fn clone(&self) -> DependencyGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DependencyGraph

Source§

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

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

impl Default for DependencyGraph

Source§

fn default() -> DependencyGraph

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more