Challenge: Check If a Graph is Strongly Connected

Given a graph, check whether it is strongly connected or not.

Problem statement

Implement a function that tells us whether a graph is strongly connected or not.

A directed graph is strongly connected if there is a path between any two pairs of vertices.

Input

A directed graph and its source

Output

True if it’s a strongly connected graph but False otherwise

Sample input

Graph:

Vertex Edges
0 1
1 2
2 3, 4
3 0
4 2

Sample output

result = True

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.