Problem of the day
Use zero-based indexing for the vertices.
The given graph doesn’t contain any self-loops.
The very first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of every test case contains two space-separated integers ‘V’ and ‘E’ denoting the number of vertices and the number of edges present in the graph.
The next ‘E’ lines contain two space-separated integers ‘a’ and ‘b’ denoting a directed edge from vertex ‘a’ to ‘b’.
For each test case, return an integer denoting the number of strongly connected components (SCCs) present in the graph.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= V <= 10^4
0 <= E <= 10^4
0 <= a, b < V
Time Limit: 1 sec
1
5 6
0 1
1 2
1 4
2 3
3 2
4 0
2
For the first test case, the graph is shown below. There are two SCCs in the graph, which are enclosed in the boxes as shown in the image below.
2
1 0
4 4
0 1
1 2
2 3
3 1
1
2