#[non_exhaustive]pub struct DepGraph { /* private fields */ }Expand description
Dependency graph wrapper around petgraph.
Implementations§
Source§impl DepGraph
impl DepGraph
Sourcepub fn from_project_graph(pg: &ProjectGraph) -> Self
pub fn from_project_graph(pg: &ProjectGraph) -> Self
Build from a ProjectGraph. Edges go from dependent → dependency.
Sourcepub fn affected_by(&self, changed: &HashSet<PackageId>) -> HashSet<PackageId>
pub fn affected_by(&self, changed: &HashSet<PackageId>) -> HashSet<PackageId>
Given a set of directly changed packages, return all transitively affected packages (changed + everything that depends on them).
Uses BFS on the reversed graph: if A→B means “A depends on B”, then in the reversed graph B→A, and BFS from a changed node B finds all packages that transitively depend on B.
Sourcepub fn explain_affected(
&self,
changed: &HashSet<PackageId>,
affected: &HashSet<PackageId>,
) -> Vec<(PackageId, Vec<PackageId>)>
pub fn explain_affected( &self, changed: &HashSet<PackageId>, affected: &HashSet<PackageId>, ) -> Vec<(PackageId, Vec<PackageId>)>
For each affected package, return the shortest dependency chain back to a directly changed package. Uses BFS on the reversed graph, tracking parents.
Sourcepub fn has_cycles(&self) -> bool
pub fn has_cycles(&self) -> bool
Check if the dependency graph contains any cycles.
Sourcepub fn find_cycles(&self) -> Vec<Vec<PackageId>>
pub fn find_cycles(&self) -> Vec<Vec<PackageId>>
Find and return all cycles in the graph (SCCs with size > 1).
Sourcepub fn to_dot_with_affected(
&self,
changed: &HashSet<PackageId>,
affected: &HashSet<PackageId>,
) -> String
pub fn to_dot_with_affected( &self, changed: &HashSet<PackageId>, affected: &HashSet<PackageId>, ) -> String
Enhanced DOT output where affected nodes are colored red and changed nodes are orange.
Sourcepub fn all_packages(&self) -> Vec<&PackageId>
pub fn all_packages(&self) -> Vec<&PackageId>
Return all package IDs in the graph.