pub struct DependencyGraph { /* private fields */ }Expand description
Efficient dependency graph representation optimized for PageRank computation
Implementations§
Source§impl DependencyGraph
Graph construction and manipulation operations
impl DependencyGraph
Graph construction and manipulation operations
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with initial capacity hint for performance optimization
Sourcepub fn add_node(&mut self, node_id: NodeId) -> Result<()>
pub fn add_node(&mut self, node_id: NodeId) -> Result<()>
Add a node to the graph (can exist without edges)
Sourcepub fn add_node_with_metadata(
&mut self,
node_id: NodeId,
metadata: NodeMetadata,
) -> Result<()>
pub fn add_node_with_metadata( &mut self, node_id: NodeId, metadata: NodeMetadata, ) -> Result<()>
Add a node with metadata
Sourcepub fn add_edge(&mut self, from_node: NodeId, to_node: NodeId) -> Result<()>
pub fn add_edge(&mut self, from_node: NodeId, to_node: NodeId) -> Result<()>
Add an import edge: from_file imports to_file
Sourcepub fn add_edges(&mut self, edges: &[(NodeId, NodeId)]) -> Result<()>
pub fn add_edges(&mut self, edges: &[(NodeId, NodeId)]) -> Result<()>
Add multiple edges efficiently (batch operation)
Sourcepub fn remove_node(&mut self, node_id: &NodeId) -> Result<bool>
pub fn remove_node(&mut self, node_id: &NodeId) -> Result<bool>
Remove a node and all its edges
Sourcepub fn remove_edge(
&mut self,
from_node: &NodeId,
to_node: &NodeId,
) -> Result<bool>
pub fn remove_edge( &mut self, from_node: &NodeId, to_node: &NodeId, ) -> Result<bool>
Remove an edge between two nodes
Sourcepub fn contains_node(&self, node_id: &NodeId) -> bool
pub fn contains_node(&self, node_id: &NodeId) -> bool
Check if a node exists in the graph
Sourcepub fn contains_edge(&self, from_node: &NodeId, to_node: &NodeId) -> bool
pub fn contains_edge(&self, from_node: &NodeId, to_node: &NodeId) -> bool
Check if an edge exists between two nodes
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the graph
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the total number of edges in the graph
Source§impl DependencyGraph
Degree and neighbor query operations
impl DependencyGraph
Degree and neighbor query operations
Sourcepub fn in_degree(&self, node_id: &NodeId) -> usize
pub fn in_degree(&self, node_id: &NodeId) -> usize
Get in-degree of a node (number of files that import this node)
Sourcepub fn out_degree(&self, node_id: &NodeId) -> usize
pub fn out_degree(&self, node_id: &NodeId) -> usize
Get out-degree of a node (number of files this node imports)
Sourcepub fn outgoing_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>
pub fn outgoing_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>
Get nodes that this node imports (outgoing edges)
Sourcepub fn incoming_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>
pub fn incoming_neighbors(&self, node_id: &NodeId) -> Option<&BTreeSet<NodeId>>
Get nodes that import this node (incoming edges) - important for PageRank
Sourcepub fn all_neighbors(&self, node_id: &NodeId) -> HashSet<&NodeId>
pub fn all_neighbors(&self, node_id: &NodeId) -> HashSet<&NodeId>
Get both incoming and outgoing neighbors
Sourcepub fn get_degree_info(&self, node_id: &NodeId) -> Option<DegreeInfo>
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
impl DependencyGraph
Node metadata and information queries
Sourcepub fn node_metadata(&self, node_id: &NodeId) -> Option<&NodeMetadata>
pub fn node_metadata(&self, node_id: &NodeId) -> Option<&NodeMetadata>
Get metadata for a node
Sourcepub fn set_node_metadata(
&mut self,
node_id: NodeId,
metadata: NodeMetadata,
) -> Result<()>
pub fn set_node_metadata( &mut self, node_id: NodeId, metadata: NodeMetadata, ) -> Result<()>
Set metadata for a node
Sourcepub fn entrypoint_nodes(&self) -> Vec<&NodeId> ⓘ
pub fn entrypoint_nodes(&self) -> Vec<&NodeId> ⓘ
Get all entrypoint nodes
Sourcepub fn test_nodes(&self) -> Vec<&NodeId> ⓘ
pub fn test_nodes(&self) -> Vec<&NodeId> ⓘ
Get all test nodes
Source§impl DependencyGraph
Specialized operations for PageRank computation
impl DependencyGraph
Specialized operations for PageRank computation
Sourcepub fn pagerank_iterator(
&self,
) -> impl Iterator<Item = (&NodeId, Option<&BTreeSet<NodeId>>)>
pub fn pagerank_iterator( &self, ) -> impl Iterator<Item = (&NodeId, Option<&BTreeSet<NodeId>>)>
Get all nodes with their reverse edge neighbors (for PageRank iteration)
Sourcepub fn dangling_nodes(&self) -> Vec<&NodeId> ⓘ
pub fn dangling_nodes(&self) -> Vec<&NodeId> ⓘ
Get dangling nodes (nodes with no outgoing edges)
Sourcepub fn estimate_scc_count(&self) -> usize
pub fn estimate_scc_count(&self) -> usize
Get strongly connected components (simplified estimation for statistics)
Sourcepub fn is_strongly_connected(&self) -> bool
pub fn is_strongly_connected(&self) -> bool
Check if the graph is strongly connected (simplified check)
Source§impl DependencyGraph
Concurrent graph operations for performance
impl DependencyGraph
Concurrent graph operations for performance
Sourcepub fn into_concurrent(self) -> ConcurrentDependencyGraph
pub fn into_concurrent(self) -> ConcurrentDependencyGraph
Create a thread-safe concurrent graph for parallel operations
Trait Implementations§
Source§impl Clone for DependencyGraph
impl Clone for DependencyGraph
Source§fn clone(&self) -> DependencyGraph
fn clone(&self) -> DependencyGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DependencyGraph
impl Debug for DependencyGraph
Auto Trait Implementations§
impl Freeze for DependencyGraph
impl RefUnwindSafe for DependencyGraph
impl Send for DependencyGraph
impl Sync for DependencyGraph
impl Unpin for DependencyGraph
impl UnwindSafe for DependencyGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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