Schedules graph node execution by computing topological ordering, detecting structural issues (cycles, unreachable nodes), and determining which nodes are ready to run given a set of already-completed nodes.

All methods are pure and stateless with respect to execution — the scheduler only reads the static graph structure provided at construction time.

Constructors

Methods

  • Returns real node ids in a valid topological execution order using Kahn's algorithm (BFS over in-degree).

    START and END sentinels are intentionally excluded from the returned array because they are virtual control-flow markers, not executable nodes.

    If the graph contains a cycle, the returned array will be shorter than nodeIds.size — use hasCycles to distinguish this case explicitly.

    Returns string[]

    Ordered array of real node ids; empty if there are no real nodes.

  • Returns true if the graph contains at least one directed cycle among the real nodes (sentinels are excluded from cycle detection).

    Implemented by comparing the length of the topological sort result against the total number of real nodes: Kahn's algorithm processes every node in a DAG, so any shortfall indicates nodes trapped inside a cycle.

    Returns boolean

    true when a cycle exists; false for a valid DAG.

  • Returns the ids of all real nodes that are eligible to execute next, given the set of nodes that have already finished (completed or skipped).

    A node is "ready" when:

    1. It has not already completed or been skipped.
    2. Every one of its predecessors is either the START sentinel or a member of the completed/skipped set.

    Parameters

    • completedNodeIds: string[]

      Node ids that have successfully finished execution.

    • skippedNodeIds: string[] = []

      Node ids that were bypassed (e.g. via conditional routing).

    Returns string[]

    Array of node ids that can be dispatched for execution immediately.

  • Returns the ids of all real nodes that are not reachable from the START sentinel via a BFS traversal of the adjacency list.

    Unreachable (orphan) nodes indicate a structural authoring error: they can never execute because no execution path leads to them. The runtime may choose to warn, error, or prune these nodes before starting a run.

    Returns string[]

    Array of node ids that cannot be reached from START; empty for a well-formed graph.