|
|
We do this for every node x
for ( each node "n" ∈ G )
{
Find all nodes x that can be reached by a traveral starting in "n";
if ( # nodes reached != N )
return( G is not strongly connected );
}
return( G is strongly connected );
|
|
|
|
Observation:
|
Note:
|
|
Select an arbitrary node x;
A = set of node reached by a DFS/BFS in the forward path graph starting at x;
if ( A ≠ all nodes in graph )
{
return ( not strongly connected );
}
B = set of node reached by a DFS/BFS in the reverse path graph starting at x;
if ( B ≠ all nodes in graph )
{
return ( not strongly connected );
}
return ( strongly connected );
|