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

  • Home
  • SEARCH
  • 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 8735655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:06:46+00:00 2026-06-13T10:06:46+00:00

By now, I have used the following algorithm for finding the strongly connected components

  • 0

By now, I have used the following algorithm for finding the strongly connected components of a graph.

  1. call DFS(G) to compute the finishing time f[v] for every vertex v, sort the vertices of G in decreasing order of their finishing time;

  2. compute the transpose GT of G;

  3. Perform another DFS on G, this time in the main for-loop we go through the vertices of G
    in the decreasing order of f[v];

  4. output the vertices of each tree in the DFS forest (formed by the second DFS) as a separate
    strongly connected component.

.

But I was wondering if it is possible to find all the strongly connected components in only one DFS.

Any help in this regard would be highly appreciated.

  • 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-13T10:06:47+00:00Added an answer on June 13, 2026 at 10:06 am

    Check out, Algorithm Design Manual by Steven Skiena. It calculates SCC in one DFS. It’s based on the concept of oldest reachable vertex.

    Initialize each vertex’s reachable vertex and SCComponent# to itself in the beginning.

    low[i] = i;
    scc[i] = -1;
    

    Do a DFS on the digraph, you are interested only in back edges and cross edges because these two edges will tell you if you’ve encountered a back edge and entering 1 component from another.

      int edge_classification(int x, int y)
      {
        if (parent[y] == x) return(TREE);
        if (discovered[y] && !processed[y]) return(BACK);
        if (processed[y] && (entry_time[y]>entry_time[x])) return(FORWARD);
        if (processed[y] && (entry_time[y]<entry_time[x])) return(CROSS);
         printf("Warning: unclassified edge (%d,%d)\n",x,y);
      }
    

    So when you encounter these edges, you set reachable vertex[] recursively, based on the entry times.
    if (class == BACK) {
    if (entry_time[y] < entry_time[ low[x] ] )
    low[x] = y;
    }

    if (class == CROSS) 
    {
                if (scc[y] == -1)  /* component not yet assigned */
                        if (entry_time[y] < entry_time[ low[x] ] )
                                low[x] = y;
    }
    

    A new strongly connected component is found whenever the lowest reachable vertex from vertex ‘v’ is itself (loop can say, a->b->c->a, lowest reachable vertex of a is a).

    process_vertex_early(int v)
    {
        push(&active,v);
    }
    

    After DFS for a vertex is complete (DFS for it’s neighbors would have been completed too), check the lowest reachable vertex for it:

    if (low[v] == v) 
    {     /* edge (parent[v],v) cuts off scc */
              pop_component(v);
    }
    
    if (entry_time[low[v]] < entry_time[low[parent[v]]])
              low[parent[v]] = low[v];
    

    pop_component(…) just pops from the stack until this component is found. If a->b->c->a is scanned the stack will have a(bottom)->b->c(top).. pop until vertex ‘a’ is seen. You get an SCC for ‘a’..and similarly you get all connected components in one DFS.

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

Sidebar

Related Questions

i have used the following query to get time range based count. subtract currentime
Since now I have only used plugin for editing and the way I use
I have used PyGame for a while now, and quite enjoyed doing so, but
I have used RPC for years but am now in a situation where we
I have used my local iis to test the site and now that its
I have used sp_addlinkedserver to access the remote machines db now i am writing
I have used this forum for a while now to find answers to some
I have used a generalized additive model to analyse some data and now wish
I have used the conditional operator in many places within my Java application. Now
I have used raphael js for drwaing my flowchart in internet explorer 8. Now

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.