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
Kosaraju’s algorithm can find the strongly connected components (SCCs) of a graph in linear time.
In the above approach, we have used DFS. You can also use BFS, but the idea will remain the same.
Minimum Swaps To Make Identical Array
Find Center of Star Graph
Critical Connections in a Network
Critical Connections in a Network
Critical Connections in a Network
Critical Connections in a Network
COUNT ISLANDS
Distance to a Cycle in Undirected Graph