Skip to main content

would_create_cycle

Function would_create_cycle 

Source
pub fn would_create_cycle(
    task_id: &str,
    depends_on_id: &str,
    existing_deps: &[TaskDependency],
) -> bool
Expand description

Check whether adding (task_id → depends_on_id) would create a cycle.

Uses BFS upstream traversal: starting from depends_on_id, follow all outgoing dependencies. If we reach task_id, there’s a cycle.

§Arguments

  • task_id — the task that would be blocked
  • depends_on_id — the task it would depend on
  • existing_deps — all current dependencies in the system

Returns true if adding this edge would create a cycle.