next up previous
Next: Planarity Testing Up: Easy Graph Problems Previous: Depth-First Search

Topological Sorting

gif Perform a depth-first-search. Label vertices in reverse order as they are marked fully-explored. Consider the edge (u,v), encountered during exploration of u. If v undiscovered tex2html_wrap_inline538 DFS(v) before continuing with tex2html_wrap_inline542 marked fully-explored before u. If v discovered, but not fully-explored tex2html_wrap_inline538 this can't happen because topological sorting can only be performed on directed-acyclic-graphs(DAG). That is, a directed graph without cycles. If v is fully-explored tex2html_wrap_inline538 labeled before tex2html_wrap_inline554 before v in topological order.



Nitin Sharma
Wed Oct 8 17:46:14 PDT 1997