Skip to main content

Module dependency_graph

Module dependency_graph 

Source
Expand description

Task dependency graph with topological scheduling, cycle detection, and critical-path analysis.

This module provides a lightweight, metadata-only DAG for expressing tasks with explicit data dependencies. Unlike super::TaskGraph which carries typed compute closures, DependencyGraph stores only scheduling metadata (name, priority, cost) so it can be used for planning without executing.

§Overview

TypeDescription
DependencyGraphDAG container for task metadata and dependencies
DepTaskNodeTask node with name, priority, cost, and metadata
DependencyGraphConfigConfiguration for graph behaviour
TopologicalAlgorithmChoice of Kahn vs DFS topological sort

§Example

use scirs2_core::task_graph::dependency_graph::{DependencyGraph, DependencyGraphConfig};
use std::collections::HashSet;

let mut g = DependencyGraph::new(DependencyGraphConfig::default());
let a = g.add_task("fetch", 1);
let b = g.add_task("process", 0);
let c = g.add_task("store", 0);
g.add_dependency(b, a).expect("b depends on a");
g.add_dependency(c, b).expect("c depends on b");

let order = g.topological_sort().expect("acyclic");
assert_eq!(order.len(), 3);

let completed: HashSet<u64> = [a].into();
assert!(g.is_ready(b, &completed));
assert!(!g.is_ready(c, &completed));

Structs§

DepTaskNode
A single node in a DependencyGraph.
DependencyGraph
A directed-acyclic graph (DAG) of tasks with metadata only.
DependencyGraphConfig
Configuration for DependencyGraph behaviour.

Enums§

TopologicalAlgorithm
Choice of algorithm for topological sorting.

Type Aliases§

TaskId
Opaque 64-bit identifier for tasks in a DependencyGraph.