DFS numbering: we assign numbers in the order with which nodes “finish”.
- A node is finished when it backtracks; with a stack, it would be when the value is popped off the stack
DAG
- Topological Sort
- “the point of this exercise is that you’re completely drunk”
Theorem: A digraph has a topological sort iff is a DAG.
Proof: FTSOC assume has a cycle .
We have and so
We have proven if has a topological sort, then must be a DAG.