Compute deterministic ready batches
Implement ready_batches(graph), returning lexicographically sorted dependency layers for a closed DAG. All nodes, including roots, must be dictionary keys.
Your task
- Return an empty list for an empty graph.
- Each batch contains every remaining node whose predecessors are complete, sorted by node name.
- Reject an unknown predecessor or a cycle with ValueError.
- Repeated predecessor entries are equivalent to one edge; do not mutate the input.
Examples
EXAMPLE 1
Input{'a': [], 'b': ['a'], 'c': []}
Output[['a', 'c'], ['b']]
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor