Click here to Skip to main content
15,068,988 members
Please Sign up or sign in to vote.
1.50/5 (3 votes)
See more:
Given a DAG (Directed Acyclic Graph), assume 20,000 vertices and 50,000 edges. What is the minimum amount of edges you need to insert in order to turn the graph into a strongly connected graph? What are those new edges that need to be added?

1 solution

The question can be understood in two different ways.

1) Calculate the required number of edges based just on the information given, one solution of all possible graphs of given number of vertices and edges. This problem has no unambiguous solution. This is easy to illustrate on a graph with three vertices and two edges. Draw the two edges in all possible ways, and you will see that the solution may require adding either one or two edges — it depends on the direction of initial edges.

2) The question may be about the algorithm of finding the minimum number of additional edges based on full information on the initial DAG. This problem seems to be quite non-trivial to me. It is relatively trivial to calculate if the graph is strongly connected, it's also pretty easy to find a way to complement a graph to a strongly connected somehow, but it seems hard to prove that any particular solution is minimal.

Sorry that's all I can say right now. Maybe a simple algorithm exists which I just fail to see. Perhaps this problem is not quite up to the CodeProject's quick Questions & Answers. And it looks like you're supposed to solve the problem independently, isn't that so? :-)


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900