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 8623205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:13:43+00:00 2026-06-12T07:13:43+00:00

I am trying to create strongly connected components from a directed acyclic graph. The

  • 0

I am trying to create strongly connected components from a directed acyclic graph.

The input is a list of edges in form

1 2
3 5
etc

I need to create an outpoint of a minimal set of edges to be added to the given graph to make a graph of strongly connected components….

Any ideas?

Here’s an example of what I’m looking for:

Given the input:

1 3
1 4
2 3
2 4
5 7
5 8
6 8
6 9

The output would be the minimum number of edges necessary for addition to create strongly connected components.

Output:

3 1
4 5
7 6
8 1
9 2
  • 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-12T07:13:45+00:00Added an answer on June 12, 2026 at 7:13 am

    Assuming there are no isolated vertices in the graph you only need to add max(|sources|,|sinks|) edges to make it strongly connected.

    Let T={t1,…,tn} be the sinks and {s1,…,sm} be the sources of the DAG. Assume that n <= m. (The other case is very similar). Consider a bipartite graph G(T,S) between the two sets defined as follows. G(T,S) has an edge (ti,sj) if and only if ti can be reached from sj.

    Let M be a maximal matching in G(T,S). Without loss of generality assume that M consists of k edges: {(t1,s1),(t2,s2),…,(tk,sk)}. In the original graph DAG G, add directed-edges {(t1->s2),(t2->s3),…,(tk−1->sk),(tk->s1)}. It’s easy to see that by adding these edges, the vertices induced by M are strongly connected in G.

    Now consider the remaining vertices in G(T,S). Because M maximal, each vertex in S−M (resp. T−M)should be connected to a vertex in T (resp. S−M). So we pair up the remaining vertices arbitrarily, say {(tk+1,sk+1),…,(tn,sn)} and add the corresponding directed edges in G. For each remaining source vertex source si (i belongs to {n+1,…,m} we add the edge (t1->si) in G. Thus the total number of edges added is max(|sources|,|sinks|).

    EDIT: Adding a couple of Examples

    For the example in your input. We fist compute a maximal matching, say:

    3--1
    4--2
    7--5
    8--6
    

    So we add the edges:

    3->2
    4->5
    7->6
    8->1
    

    The remaining (sink) vertex not present in the matching is 9 and so we add the arc from 9 to any source vertex in the matching, say 9->1.

    Here’s another example that illustrates all the steps of the algorithm:

    Input Graph:

    12 3   5    9 10  (sources)
    \|/   /|\    \/
     4   6 7 8   11   (sinks)
    

    Maximal Matching:

    4--1
    6--5
    11--9
    

    So we add the edges:

    4->5
    6->9
    11->1
    

    Now the remaining sinks are {7, 8} and the remaining sources are {2, 3, 10}. We arbitrary pair 7 with say 2 and 8 with say 3 and add:

    7->2
    8->3
    

    Finally, the remaining (source) vertex is 10 and we add:

    4->10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a strongly typed radiobuttonlist. I dont know how to
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create a strongly type html helper extension for a date picker
i'm trying to create a strongly-typed view using Visual Studio 2008. I can right-click
I'm trying to create an event delegate where the parameter is strongly typed to
I'm trying to create a strongly-typed Dictionary class in VB.NET. I'm tired of typing
I am trying to create url routing with strongly typed objects for pages but
I'm attempting to create a strongly-typed view based on a class from another assembly.
I'm trying to create a strongly typed partial view <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master
I'm trying to create a strongly typed view model as John Sheehan suggests here

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.