My issue
Topological sort
A Directed Acyclic Graph (DAG) is a directed graph that contains no cycles.
Topological Sorting of DAG is a linear ordering of vertices such that for every directed edge from vertex uu to vertex vv, vertex uu comes before vv in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.
Given a DAG consisting of VV vertices and EE edges, you need to find out any topological sorting of this DAG. Output the topological sort of the vertices of the given DAG.
Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
Each test case consists of multiple lines of input.
The first line of each test case contains two space-separated integers NN and MM — the number of vertices and edges of the graph, respectively.
The next MM lines describe the edges. The ii-th of these MM lines contains two space-separated integers uiui and vivi, denoting an edge between uiui and vivi.
Output Format
Print the topological sort of the vertices of the given DAG.
Constraints
1≤T≤501≤T≤50
1≤V≤1041≤V≤104
0≤E≤1040≤E≤104
0≤u,v<V0≤u,v<V
give the code
My code
#include <stdio.h>
int main(void) {
// your code goes here
}
Learning course: Analysis and Design of Algorithms
Problem Link: Topological sort in Analysis and Design of Algorithms