pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph for managing transitive dependencies.
This graph tracks dependencies between resources and provides algorithms for cycle detection and topological ordering.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn add_dependency(&mut self, from: DependencyNode, to: DependencyNode)
pub fn add_dependency(&mut self, from: DependencyNode, to: DependencyNode)
Add a dependency relationship to the graph.
from depends on to, meaning to must be installed before from.
Sourcepub fn detect_cycles(&self) -> Result<()>
pub fn detect_cycles(&self) -> Result<()>
Detect cycles in the dependency graph using DFS with colors.
Returns an error containing the cycle path if a cycle is detected.
Sourcepub fn topological_order(&self) -> Result<Vec<DependencyNode>>
pub fn topological_order(&self) -> Result<Vec<DependencyNode>>
Get the topological order for installation.
Returns nodes in an order where all dependencies come before their dependents. This ensures that resources are installed in the correct order.
Sourcepub fn get_transitive_deps(
&self,
node: &DependencyNode,
) -> HashSet<DependencyNode>
pub fn get_transitive_deps( &self, node: &DependencyNode, ) -> HashSet<DependencyNode>
Get all transitive dependencies for a given node.
Returns a set of all nodes that the given node depends on, directly or indirectly.
Sourcepub fn get_direct_deps(&self, node: &DependencyNode) -> Vec<DependencyNode>
pub fn get_direct_deps(&self, node: &DependencyNode) -> Vec<DependencyNode>
Get direct dependencies for a given node.
Returns only the immediate dependencies, not transitive ones.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the total number of nodes in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the total number of edges (dependencies) in the graph.
Sourcepub fn nodes(&self) -> Vec<DependencyNode>
pub fn nodes(&self) -> Vec<DependencyNode>
Get all nodes in the graph.
Sourcepub fn to_tree_string(&self, root: &DependencyNode) -> String
pub fn to_tree_string(&self, root: &DependencyNode) -> String
Build a human-readable dependency tree representation.
Returns a string showing the dependency hierarchy.
Trait Implementations§
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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