7. Topological Sort
Previous6. Floyd Warshall's Algorithm(All Pair Sortest Path)Next8. Find if the given edge is a bridge in graph.
Last updated
Last updated
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge (u v) , vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.
For the sample graph shown above, one of the possible ordering of courses is: C6 ➔ C4 ➔ C1 ➔ C5 ➔ C2 ➔ C3
and another possible ordering of subjects is
C6 ➔ C4 ➔ C5 ➔ C1 ➔ C2 ➔ C3
.