A strongly connected component is the component of a directed graph that has a path from every vertex to every other vertex in that component. It can only be used in a directed graph.
For example, The below graph has two strongly connected components {1,2,3,4} and {5,6,7} since there is path from each vertex to every other vertex in the same strongly connected component.
Strongly Connected Component
Difference between Connected and Strongly Connected Components?
Connectivity in a undirected graph refers to whether two vertices are reachable from each other or not. Two vertices are said to be connected if there is path between them. Meanwhile Strongly Connected is applicable only to directed graphs. A subgraph of a directed graph is considered to be an Strongly Connected Components (SCC) if and only if for every pair of vertices A and B, there exists a path from A to B and a path from B to A. Let’s see why the standard dfs method to find connnected components in a graph cannot be used to determine strongly connected components.
Now, Consider the following graph
Now, let’s start a dfs call from vertex 1 to visit other vertices.
Why conventional DFS method cannot be used to find the strongly connected components?
All the vertices can be reached from vertex 1. But vertices 1 and 5,6,7 can not be in the same strongly connected component because there is no directed path from vertex 5,6 or 7 to vertex 1. The graph has two strongly connected components {1,2,3,4} and {5,6,7}. So the conventional dfs method cannot be used to find the strongly connected components.
Connecting Two Strongly Connected Component by a Unidirectional Edge
Two different connected components becomes a single component if a edge is added between a vertex from one component to a vertex of other component. But this is not the case in strongly connected components. Two strongly connected components doesn’t become a single strongly connected component if there is only a unidirectional edge from one SCC to other SCC.
Brute Force Approach for Finding Strongly Connected Components:
The simple method will be for each vertex i (which is not a part of any strongly component) find the vertices which will be the part of strongly connected component containing vertex i. Two vertex i and j will be in the same strongly connected component if they there is a directed path from vertex i to vertex j and viceversa.
Let’s understand the approach with the help of following example:
 Starting with vertex 1. There is path from vertex 1 to vertex 2 and viceversa. Similarly there is a path from vertex 1 to vertex 3 and vice versa. So, vertex 2 and 3 will be in the same Strongly Connected Component as vertex 1. Although there is directed path form vertex 1 to vertex 4 and vertex 5. But there is no directed path from vertex 4,5 to vertex 1 so vertex 4 and 5 won’t be in the same Strongly Connected Component as vertex 1. Thus Vertex 1,2 and 3 forms a Strongly Connected Component.
 For Vertex 2 and 3, there Strongly Connected Component has already been determined.
 For Vertex 4, there is a path from vertex 4 to vertex 5 but there is no path from vertex 5 to vertex 4. So vertex 4 and vertex won’t be in the Same Strongly Connected Component. So both Vertex 4 and Vertex 5 will be part of Single Strongly Connected Component.
 Hence there will be 3 Strongly Connected Component {1,2,3}, {4} and {5}.
Below is the implementation of above approach:
C++

Strongly Connected Components are:
1 2 3
4
5
Time complexity: O(N3) because for each pair of vertices we are checking whether a path exists between them.
Auxiliary Space: O(N)
Related article for finding strongly connected components in a directed graph in O(V+E) time:
Last Updated :
09 Aug, 2023
Like Article
Save Article