DependencyGraph

Struct DependencyGraph 

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

Efficient dependency graph representation optimized for PageRank computation

Implementations§

Source§

impl DependencyGraph

Graph construction and manipulation operations

Source

pub fn new() -> Self

Create a new empty dependency graph

Source

pub fn with_capacity(capacity: usize) -> Self

Create with initial capacity hint for performance optimization

Source

pub fn add_node(&mut self, node_id: NodeId) -> Result<()>

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

Source

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

Add a node with metadata

Source

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

Add an import edge: from_file imports to_file

Source

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

Add multiple edges efficiently (batch operation)

Source

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

Remove a node and all its edges

Source

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

Remove an edge between two nodes

Source

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

Check if a node exists in the graph

Source

pub fn contains_edge(&self, from_node: &NodeId, to_node: &NodeId) -> 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 = &NodeId>

Get all nodes in the graph

Source

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

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: &NodeId) -> usize

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

Source

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

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

Source

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

Get total degree of a node (in + out)

Source

pub fn outgoing_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>

Get nodes that this node imports (outgoing edges)

Source

pub fn incoming_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>

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

Source

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

Get both incoming and outgoing neighbors

Source

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

Get degree information for a node

Source§

impl DependencyGraph

Node metadata and information queries

Source

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

Get metadata for a node

Source

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

Set metadata for a node

Source

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

Get all entrypoint nodes

Source

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

Get all test nodes

Source

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

Get nodes by language

Source§

impl DependencyGraph

Specialized operations for PageRank computation

Source

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

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

Source

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

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

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

impl Default for DependencyGraph

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