Topological Order of a Scenario Graph
Problem A visual automation scenario is a graph of connected modules, where an edge from module A to module B means B depends on A's output. Given the module dependencies, compute a valid execution order (each module runs only after its dependencies) and detect whether the graph contains a cycle (which makes execution impossible).
Input / Output
- Input: the set of modules and their directed dependency edges.
- Output: a valid execution order of the modules, or a signal that a cycle makes ordering impossible.
Constraints
- Up to 10^4 modules.
- The dependency graph should be a DAG; a cycle is an error to report.
Example
A -> B -> C=> run orderA, B, C. A cycle (e.g.A -> B -> A) is invalid.
added …