Graph - 8: Check if Directed Graph is Strongly Connected

preview_player
Показать описание
Solution:
- Strongly connected - If we can reach to all nodes from any node
- We'll achieve this via DFS approach.
- For each vertex, we'll call dfs as start point
- Now when you start dfs from source index, it mark visited to all components to which it's connected to
- So via visted boolean array, we can identify if element is visited or not
- So once we're done dfs for a index, all element in visited array should be True, if any value is false, we'll return false
- So at last return visited[destination_index]

Time Complexity: O(V * (V + E))

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★
Рекомендации по теме
Комментарии
Автор

Thank You SO MUCH for this. Very helpful videos!!!

maneekamishra
Автор

Thank you so much for all your videos. It's really helpful. One question here: When all nodes are connected, why do we need to do dfs for every single vertex and verify viewed. Instead can't we just check the length of the adjacent list of every singe node and equal (n-1) where n is the length of the node, then it's TRUE? Please correct me if I'm wrong

muthaiahpalaniappan