PythiloLesson 5 of 8 · progress kept in this browser

Schedule dependencies with indegrees

A directed edge from a prerequisite to a dependent task means the prerequisite must run first. Count incoming edges and begin with nodes whose counts are zero. Removing one ready node releases its outgoing edges. If unfinished nodes remain but none is ready, the graph contains a cycle and no valid schedule exists.

from collections import deque
ready = deque(["parse"])
print(ready.popleft())
Your task

Write task_order(graph). The dict maps every node to its outgoing neighbours, and every neighbour is also a key. Return any topological ordering, or None for a cycle. Include isolated nodes.