Topological sort linearly orders the vertices of a DAG (directed acyclic graph) so every edge u->v has u before v. It answers "in what order can I do these tasks given their dependencies?"
The idea
Two common approaches: (repeatedly remove nodes with in-degree 0) or (reverse post-order). A valid ordering exists .
