pub struct TaskGraph { /* private fields */ }Expand description
Task dependency graph
Wraps petgraph DiGraph to provide task-specific operations. Nodes are Tasks, edges are DependencyEdge relationships.
Implementations§
Source§impl TaskGraph
impl TaskGraph
Sourcepub fn add_task(&mut self, task: Task) -> NodeIndex
pub fn add_task(&mut self, task: Task) -> NodeIndex
Add a task to the graph
Returns the node index for the added task.
Sourcepub fn add_dependency(&mut self, task_a_id: &str, task_b_id: &str) -> Result<()>
pub fn add_dependency(&mut self, task_a_id: &str, task_b_id: &str) -> Result<()>
Add a dependency: task_a blocks task_b (b depends on a)
Returns error if either task ID not found.
Sourcepub fn topological_sort(&self) -> Result<Vec<String>>
pub fn topological_sort(&self) -> Result<Vec<String>>
Perform topological sort
Returns tasks in valid execution order (dependencies first). Returns error if graph contains cycles.
Sourcepub fn detect_cycles(&self) -> Vec<Vec<String>>
pub fn detect_cycles(&self) -> Vec<Vec<String>>
Detect cycles in the graph
Returns list of cycles, where each cycle is a list of task IDs. Empty list means no cycles (valid DAG).
Sourcepub fn critical_path(&self) -> Result<Vec<String>>
pub fn critical_path(&self) -> Result<Vec<String>>
Calculate critical path (longest path in DAG)
Returns list of task IDs on the critical path. Critical path represents the bottleneck (minimum time to complete all tasks).
Uses task duration estimates if available, otherwise treats all tasks as duration=1.
Sourcepub fn dependencies(&self, task_id: &str) -> Vec<String>
pub fn dependencies(&self, task_id: &str) -> Vec<String>
Get dependencies for a task (tasks that this task depends on)
Sourcepub fn dependents(&self, task_id: &str) -> Vec<String>
pub fn dependents(&self, task_id: &str) -> Vec<String>
Get dependents for a task (tasks that depend on this task)