Solution Review 3: Topological Sorting of a Graph
This review provides a detailed analysis of the solution to topologically sort a graph.
We'll cover the following...
Solution: Using Recursion
Let’s have a look at the algorithm to solve this problem:
function helperFunction(currentNode) {
// mark currentNode visited
for (each vertex v that has an edge from currentNode to v) {
helperFunction(v);
}
// push currentNode to head of
...