pub struct WorkflowDag { /* private fields */ }Expand description
Workflow DAG structure.
Implementations§
Source§impl WorkflowDag
impl WorkflowDag
Sourcepub fn add_dependency(
&mut self,
from_task_id: &str,
to_task_id: &str,
edge: TaskEdge,
) -> Result<()>
pub fn add_dependency( &mut self, from_task_id: &str, to_task_id: &str, edge: TaskEdge, ) -> Result<()>
Add a dependency edge between two tasks.
Sourcepub fn get_task_mut(&mut self, task_id: &str) -> Option<&mut TaskNode>
pub fn get_task_mut(&mut self, task_id: &str) -> Option<&mut TaskNode>
Get a task by ID (mutable).
Sourcepub fn get_dependencies(&self, task_id: &str) -> Vec<String>
pub fn get_dependencies(&self, task_id: &str) -> Vec<String>
Get task dependencies (tasks that must complete before this task).
Sourcepub fn get_dependents(&self, task_id: &str) -> Vec<String>
pub fn get_dependents(&self, task_id: &str) -> Vec<String>
Get task dependents (tasks that depend on this task).
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Get the number of tasks in the DAG.
Sourcepub fn dependency_count(&self) -> usize
pub fn dependency_count(&self) -> usize
Get the number of dependencies in the DAG.
Sourcepub fn root_tasks(&self) -> Vec<&TaskNode>
pub fn root_tasks(&self) -> Vec<&TaskNode>
Get root tasks (tasks with no dependencies).
Sourcepub fn leaf_tasks(&self) -> Vec<&TaskNode>
pub fn leaf_tasks(&self) -> Vec<&TaskNode>
Get leaf tasks (tasks with no dependents).
Sourcepub fn edges(&self) -> Vec<(&str, &str, &TaskEdge)>
pub fn edges(&self) -> Vec<(&str, &str, &TaskEdge)>
Get all edges in the DAG as (from_task_id, to_task_id, edge_data) tuples.
This method is useful for visualization and serialization purposes. Returns edges in the order they are stored in the graph.
Sourcepub fn edge_pairs(&self) -> Vec<(String, String)>
pub fn edge_pairs(&self) -> Vec<(String, String)>
Get all edges with their edge types as (from_task_id, to_task_id, edge_type) tuples.
A simplified version of edges() that only returns edge types.
Sourcepub fn get_dependencies_with_edges(
&self,
task_id: &str,
) -> Vec<(String, &TaskEdge)>
pub fn get_dependencies_with_edges( &self, task_id: &str, ) -> Vec<(String, &TaskEdge)>
Get task dependencies along with their edge data.
Returns a vector of (dependency_task_id, edge_data) tuples for the given task. Dependencies are tasks that must complete before the specified task can start.
Sourcepub fn get_dependents_with_edges(
&self,
task_id: &str,
) -> Vec<(String, &TaskEdge)>
pub fn get_dependents_with_edges( &self, task_id: &str, ) -> Vec<(String, &TaskEdge)>
Get task dependents along with their edge data.
Returns a vector of (dependent_task_id, edge_data) tuples for the given task. Dependents are tasks that wait for the specified task to complete.
Sourcepub fn get_edge_between(
&self,
from_task_id: &str,
to_task_id: &str,
) -> Option<&TaskEdge>
pub fn get_edge_between( &self, from_task_id: &str, to_task_id: &str, ) -> Option<&TaskEdge>
Get the edge data between two specific tasks, if it exists.
Returns None if either task does not exist or no edge connects them.
Sourcepub fn has_dependency(&self, from_task_id: &str, to_task_id: &str) -> bool
pub fn has_dependency(&self, from_task_id: &str, to_task_id: &str) -> bool
Check if a dependency exists between two tasks.
Returns true if from_task_id has a direct edge to to_task_id.
Sourcepub fn has_dependencies(&self, task_id: &str) -> bool
pub fn has_dependencies(&self, task_id: &str) -> bool
Check if a task has any dependencies (incoming edges).
Sourcepub fn has_dependents(&self, task_id: &str) -> bool
pub fn has_dependents(&self, task_id: &str) -> bool
Check if a task has any dependents (outgoing edges).
Sourcepub fn in_degree(&self, task_id: &str) -> usize
pub fn in_degree(&self, task_id: &str) -> usize
Get the in-degree of a task (number of dependencies).
Sourcepub fn out_degree(&self, task_id: &str) -> usize
pub fn out_degree(&self, task_id: &str) -> usize
Get the out-degree of a task (number of dependents).
Sourcepub fn contains_task(&self, task_id: &str) -> bool
pub fn contains_task(&self, task_id: &str) -> bool
Check if a task exists in the DAG.
Sourcepub fn remove_task(&mut self, task_id: &str) -> Option<TaskNode>
pub fn remove_task(&mut self, task_id: &str) -> Option<TaskNode>
Remove a task from the DAG along with all its edges.
Returns the removed task, or None if the task did not exist.
Sourcepub fn edges_by_type(&self, edge_type: EdgeType) -> Vec<(&str, &str, &TaskEdge)>
pub fn edges_by_type(&self, edge_type: EdgeType) -> Vec<(&str, &str, &TaskEdge)>
Get edges filtered by edge type.
Sourcepub fn subgraph(&self, task_ids: &[&str]) -> WorkflowDag
pub fn subgraph(&self, task_ids: &[&str]) -> WorkflowDag
Get a subgraph containing only the specified tasks and edges between them.
Tasks not present in the original DAG are silently ignored.
Sourcepub fn transitive_dependencies(&self, task_id: &str) -> Vec<String>
pub fn transitive_dependencies(&self, task_id: &str) -> Vec<String>
Compute the transitive closure of dependencies for a task.
Returns all tasks that must complete (directly or transitively) before the given task can execute.
Sourcepub fn transitive_dependents(&self, task_id: &str) -> Vec<String>
pub fn transitive_dependents(&self, task_id: &str) -> Vec<String>
Compute the transitive closure of dependents for a task.
Returns all tasks that (directly or transitively) depend on the given task.
Sourcepub fn summary(&self) -> DagSummary
pub fn summary(&self) -> DagSummary
Get summary statistics about the DAG structure.
Trait Implementations§
Source§impl Clone for WorkflowDag
impl Clone for WorkflowDag
Source§fn clone(&self) -> WorkflowDag
fn clone(&self) -> WorkflowDag
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more