pub struct DependencyGraph { /* private fields */ }Expand description
A directed dependency graph for analyzing execution order.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn add_edge(&mut self, from: DepNodeId, to: DepNodeId) -> bool
pub fn add_edge(&mut self, from: DepNodeId, to: DepNodeId) -> bool
Add a dependency edge: from must complete before to.
Returns true if the edge was newly added.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the graph.
Sourcepub fn dependencies_of(&self, id: DepNodeId) -> Vec<DepNodeId>
pub fn dependencies_of(&self, id: DepNodeId) -> Vec<DepNodeId>
Get the direct dependencies (predecessors) of a node.
Sourcepub fn dependents_of(&self, id: DepNodeId) -> Vec<DepNodeId>
pub fn dependents_of(&self, id: DepNodeId) -> Vec<DepNodeId>
Get the direct dependents (successors) of a node.
Sourcepub fn topological_order(&self) -> Option<Vec<DepNodeId>>
pub fn topological_order(&self) -> Option<Vec<DepNodeId>>
Compute topological ordering using Kahn’s algorithm.
Returns None if the graph has a cycle.
Sourcepub fn transitive_dependencies(&self, id: DepNodeId) -> HashSet<DepNodeId>
pub fn transitive_dependencies(&self, id: DepNodeId) -> HashSet<DepNodeId>
Compute all transitive dependencies of a node.
Sourcepub fn compute_depths(&self) -> HashMap<DepNodeId, u32>
pub fn compute_depths(&self) -> HashMap<DepNodeId, u32>
Compute the depth of each node (longest path from a root).
Sourcepub fn parallel_levels(&self) -> Vec<Vec<DepNodeId>>
pub fn parallel_levels(&self) -> Vec<Vec<DepNodeId>>
Group nodes into parallelizable levels.
Nodes at the same level have no inter-dependencies and can run concurrently.
Sourcepub fn critical_path(&self) -> (Vec<DepNodeId>, f64)
pub fn critical_path(&self) -> (Vec<DepNodeId>, f64)
Compute the critical path (longest weighted path through the graph).
Trait Implementations§
Source§impl Debug for DependencyGraph
impl Debug for DependencyGraph
Source§impl Default for DependencyGraph
impl Default for DependencyGraph
Source§fn default() -> DependencyGraph
fn default() -> DependencyGraph
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DependencyGraph
impl RefUnwindSafe for DependencyGraph
impl Send for DependencyGraph
impl Sync for DependencyGraph
impl Unpin for DependencyGraph
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
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>
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 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>
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