Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge uv, vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.
For example, a topological sorting of the following graph is “5 4 2 3 1 0”. There can be more than one topological sorting for a graph. For example, another topological sorting of the following graph is “4 5 2 3 1 0”. The first vertex in topological sorting is always a vertex with in-degree as 0 (a vertex with no in-coming edges).
Following is a Topological Sort of the given graph 5 4 2 3 1 0
Please refer complete article on Topological Sorting for more details!
- Java Program for Pancake sorting
- Sorting in Java
- Java Program for Program to calculate area of a Tetrahedron
- Java Program for Program to find area of a circle
- Java Program for Program for array rotation
- Java Program to take Screenshots
- Java Program for QuickSort
- Java Program for ShellSort
- Java Program for Cutting a Rod | DP-13
- Program to convert Array to Set in Java
- Java Program for Gnome Sort
- Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +.......+ n/n!
- Java Program for Insertion Sort
- Java Program for Phone Mnemonics
- Java Program for factorial of a number