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
Was this helpful?
Last updated
Was this helpful?
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
.