Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:58:06+00:00 2026-06-15T13:58:06+00:00

I was reading the graph algorithms about BFS and DFS. When I was analyzing

  • 0

I was reading the graph algorithms about BFS and DFS. When I was analyzing the algorithm for finding strongly connected component in a Graph through DFS, a doubt came to my mind. For finding the strongly connected component, what book(Coremen)does, first it ran the DFS on the Graph in order to get the finish time of the vertices then again ran the DFS on the transpose of the graph in decreasing order of the finish time which we got from the first DFS. But I am not able to grasp why the second DFS must be run according to finish time.
What I mean is that even if we directly run the DFS (ignoring the finish time) on the transpose of the graph, could it also have given us the connected components because by doing the transpose we have already blocked the path to other components.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:58:07+00:00Added an answer on June 15, 2026 at 1:58 pm

    Edit- Here’s some good in-depth videos from stanford university on the topic:

    http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=IntroToAlgorithms (See 6. CONNECTIVITY IN DIRECTED GRAPHS)

    My explanation:

    It’s possible that you would incorrectly identify the entire graph as a single strongly connected component(SCC) if you don’t run the second dfs according to decreasing finish times of the first dfs.

    enter image description here

    Notice that in my example, node d would always have the lowest finish time from the first dfs. One of nodes a, b, or c will have the highest finish times. Lets assume a has the highest finish time, and so if we ran the second dfs according to decreasing finish times, a would be first.

    Now, if you ran the second dfs starting with node d in the transpose of G, you would produce a depth first forest containing the entire graph, and so conclude that the entire graph is a SCC, which is clearly false. However, if you start the dfs with a, then you would not only discover a, b, and c, as being an SCC, but the important part is that they would be marked as visited by being colored grey or black. Then when you continue the dfs on d, you wouldn’t traverse out of its SCC because you would realize that its adjacent nodes have been visited.

    If you look at cormens code for DFS,

    DFS(G)
    1 for each vertex u in G.V
    2     u.color = WHITE
    3     u.π = NIL
    4 time = 0
    5 for each vertex u in G.V
    6     if u.color == WHITE
    7         DFS-VISIT(G, u)
    
    DFS-VISIT(G, u)
    1 time = time + 1 // white vertex u has just been discovered
    2 u.d = time
    3 u.color = GRAY
    4 for each v in G.adj[u]
    5     if v.color == WHITE
    6         v.π = u
    7         DFS-VISIT(G, u)
    8 u.color = BLACK // blacken u; it is finished
    9 time = time + 1
    10 u.f = time
    

    if you didn’t use decreasing finish time, then line 6 of DFS would only be true once, because DFS-VISIT would visit the entire graph recursively. This produces a single tree in the depth first forest, and each tree is an SCC. The reasoning for a single tree is because a tree is identified by its root node having a nil predecessor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading about network flow algorithms in Robert Sedwicks book on Graph algorithms.
Reading through this excellent article about safe construction techniques by Brain Goetz, I got
I was reading about FB Graph API in this page. Please see the section
I am reading about minimum spanning trees algorithms. It is mentioned about cut. A
I have been looking at MapReduce and reading through various papers about it and
So I'm reading Robert Sedgewick's Algorithms 4th ed. book and the methods for finding
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading some questions here on SO about conversion operators and constructors got me thinking
I've been reading a lot of stackoverflow questions about how to use the breadth-first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.