Talk:Data Structures/Graphs

For DFS there are plenty of applications on wikipedia

Topological Sort (stolen from wikipedia)

Imagine nodes are jobs and edges connect one job to another that must follow it, so they form an acyclic directed graph. Topological sort arranges nodes in an acyclic directed graph so that each node is processed before the nodes that depend on it. An example of such a graph is any 'data flow' program (such as a LabView program). One algorithm to solve the topological sorting problem uses DFS.

L ← Empty list that will contain the sorted nodes while there are unmarked nodes do select an unmarked node n    visit(n) function visit(node n)    if n has a temporary mark then stop (not a DAG) if n is not marked (i.e. has not been visited yet) then mark n temporarily for each node m with an edge from n to m do visit(m) mark n permanently add n to head of L

The DFS based topological sort algorithm above is illustrated with an animated examples at the data structures visualization website.