pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph built from tasks.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn from_collection(collection: &TaskCollection) -> Self
pub fn from_collection(collection: &TaskCollection) -> Self
Build a graph from a task collection.
Sourcepub fn from_tasks(tasks: Vec<&Task>) -> Self
pub fn from_tasks(tasks: Vec<&Task>) -> Self
Build a graph from a list of tasks.
Sourcepub fn add_dependency(&mut self, from: &str, to: &str)
pub fn add_dependency(&mut self, from: &str, to: &str)
Add a dependency edge (from must complete before to).
Sourcepub fn has_cycles(&self) -> bool
pub fn has_cycles(&self) -> bool
Check if the graph has cycles.
Sourcepub fn find_cycles(&self) -> Vec<Vec<TaskId>>
pub fn find_cycles(&self) -> Vec<Vec<TaskId>>
Find all cycles in the graph. Returns a list of cycles, where each cycle is a list of task IDs.
Sourcepub fn topological_order(&self) -> Option<Vec<TaskId>>
pub fn topological_order(&self) -> Option<Vec<TaskId>>
Get topological order of tasks. Returns None if there are cycles.
Sourcepub fn dependencies(&self, task_id: &str) -> Vec<TaskId> ⓘ
pub fn dependencies(&self, task_id: &str) -> Vec<TaskId> ⓘ
Get tasks that this task depends on (direct).
Sourcepub fn dependents(&self, task_id: &str) -> Vec<TaskId> ⓘ
pub fn dependents(&self, task_id: &str) -> Vec<TaskId> ⓘ
Get tasks that depend on this task (direct).
Sourcepub fn parallel_groups(&self) -> Vec<Vec<TaskId>>
pub fn parallel_groups(&self) -> Vec<Vec<TaskId>>
Get parallel work groups (generations). Tasks in the same group have no dependencies on each other.
Sourcepub fn critical_path(&self) -> Vec<TaskId> ⓘ
pub fn critical_path(&self) -> Vec<TaskId> ⓘ
Get critical path (longest path through graph). Returns the sequence of tasks on the critical path.
Sourcepub fn weighted_critical_path<F>(&self, weight_fn: F) -> Vec<TaskId> ⓘ
pub fn weighted_critical_path<F>(&self, weight_fn: F) -> Vec<TaskId> ⓘ
Get weighted critical path (path with highest cumulative weight). Takes a weight function that maps task IDs to their weight.
Sourcepub fn bottlenecks(&self) -> Vec<(TaskId, usize)>
pub fn bottlenecks(&self) -> Vec<(TaskId, usize)>
Get bottleneck tasks (high betweenness centrality). Returns tasks sorted by how many paths they’re on.