Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Run the strongly connected components algorithm on the following directed graphs G. When doing DFS on GR: whenever there is a choice of vertices to explore, always pick the one that is alphabetically first.

In each case answer the following questions.

(a) In what order are the strongly connected components (SCCs) found?

(b) Which are source SCCs and which are sink SCCs?

(c) Draw the “metagraph” (each meta-node is an SCC of G).

(d) What is the minimum number of edges you must add to this graph to make it strongly connected

Short Answer

Expert verified

(a) The order of the strongly connected components are:

E,B,A,HGI,CDFJ

The order of the strongly connected components in the second graph are:

DGHIF,C,AEB

(b) The source of the first graph is EandB.

The sink of the first graph is CDFJ.

The source of the second graph is CandA.

The sink of the second graph isDGHIF.

(c) The “metagraph” of both graphs is possible.

(d) The minimum number of edges in the graph ato make it strongly connected is two. And the minimum number of edges in the graph bto make it strongly connected is also two.

Step by step solution

01

Explain Strongly Connected Components

Strongly connected components in a directed graph show that every vertex is reachable from every other vertex. The graph is strongly connected only when the graph is a directed graph.

Depth First Search (DFS) is an application of graph traversal. It traverses downwards and uses the stack as a data structure. Through this, it traverses all vertices in the downward direction one by one.

Some properties ofdepth-first search are as follows:

Using DFT, it is verified whether the graph is connected or not. It means it detects the cycle present in the graph or not.

The number of connected components is found using a depth-first search. Here stack is used as a data structure.

02

Determine the order of the strongly connected components.

Perform Depth First Search on the given graph and compute pre and post-interval for all vertices as starts from A and ends on C. Here the pre-order of vertex A is 1 and post order is 16.

After applying depth-first search traversal on this graph, the pre-order and post order of all the vertices are as follows:

A1,6,B2,3,C7,20,D10,11,E4,5,F9,18,G14,15,H12,17,I13,16,J8,19

Fig: pre and post-interval of the graph by depth-first search.

In the next step, compute the reverse graph of the given graph by changing the direction of the edges from vertices. The reversal of the graph is represented as GR.

Fig: Reversal of the graph. (GR)

After this step, run depth-first search on the graph, and during the depth-first search, process the vertices in decreasing order of their post numbers from step1.

To find the strongly connected components in this graph, determine the vertices which are forming a graph which is directly connected to its all vertices. In this order, there are four strongly connected components formed first, called CDFJ. Here Cis the source vertex, which easily is reached with all the other vertices in its own connected component. In order to find other strongly connected components are E,B,A,HGI.

So, in this graph, there are five strongly connected components, and they areE,B,A,HJI,CDFG

03

Determine the order of the strongly connected components for graph 2 .

To find the order of the strongly connected component in the graph, firstly apply the Depth-First Search on the given graph and compute pre and post-interval for all vertices. It starts from A and ends on D . Here the pre-order of vertex A is 1 , and the post-order vertex is6 . For B , the pre and post-order is given as 3,4.

After applying depth-first search traversal on this graph, the pre-order and post-order of all the vertices are as follows:

A1,6,B3,4,C7,8,D9,18,E2,5,F13,14,G10,17,H11,16,I12,15

Fig: pre and post-interval of the graph by depth-first search.

After that, compute the reverse graph of the given graph by changing the direction of the edges from vertices.

The reversal of the graph is represented as GR.

Fig: Reversal of the graph. (GR)

Run the depth-first search on the graph, and during the depth-first search, process the vertices in decreasing order of their post numbers from step1.

To find the strongly connected components in this graph, first, determine the vertices which are forming a graph that directly connected to its all vertices.

In this order, there are four different strongly connected components, and formed first is DGHIF. Here D is the source vertex, which is easily reached with all the other vertices in its own connected component.

There are also three more strongly connected components. They are C,AEB .

Here the final answer for this graph is DGHIF,C,AEB

04

Determine the sources and sinks of the strongly connected components

b).

The source SCCs and the sink SCCs are explained as follows:

The source is a vertex from where the graph starts, and the sink is the vertex where it ends. The source is the starting node, and the sink is the ending node of the graph.

Here the source of the strongly connected components are: EandBand the sink of the strongly connected components are: CDFJ

05

The sources and sinks of the strongly connected components for the second graph.

For determining the starting and the ending vertex as the source and the sink node of the second graph, take the help of the diagram.

Fig: Reversal of the graph. (GR)

So, here the source of the strongly connected components are: CandA

And the sink of the strongly connected components are: DGHIF

06

Obtain the metagraph for graph (a).

c).

The “metagraph” is defined as each meta-node in a strongly connected component of the graph. Here from each separate vertex of the strongly connected component, there is a path to the other vertex of the strongly connected component of the graph.

From A,B,E there is a path connected to the other separate path that is HGI and CDFJ. This is clearer by taking the help of the graph given below.

Metagraph of given graph (a)

07

Obtain the metagraph for graph (b).

In this graph, there are three strongly connected components of the graph, which form a sequence of nodes where every vertex is reachable from every other vertex, and this is also a connected directed graph.

In the given graph, from each separate vertex of the strongly connected component, there is a path to the other vertex of the strongly connected component of the graph. The metagraph of the given graph is shown below:

Metagraph of given graph b

Hence, the metagraph for both the given graphs is obtained.

08

Find the minimum number of edges added to the graph to make it strongly connected for graph (a).

d).

Two directed edges are required in the graph to make it strongly connected. One directed from C and A, and the other from C to E . And when it is added, it makes the graph with no source or sink node.

Thus, the minimum number of edges added to the graph to make it a strongly connected graph is two.

09

Step 9: Find the minimum number of edges added to the graph to make it strongly connected for graph (b).

d).

Two directed edges are required in the graph to make it strongly connected. One directed from E to B, and the other from D to E. When added, it makes the graph with no source or sink node. Since the meta graphs reveal a directed acyclic graph and adding any edge from sink to source creates a cycle, the entire graph is strongly connected.

Thus, the minimum number of edges added to the graph to make it strongly connected is two.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Give a linear-time algorithm for the following task.
Input: A directed acyclic graph G

Does G contain a directed path that touches every vertex exactly once?

Give an efficient algorithm that takes as input a directed acyclic graph G=V,E, and two vertices s,tV, and outputs the number of different directed paths from S to t in G.

Suppose a CS curriculum consists of n courses, all of them mandatory. The prerequisite graph G has a node for each course, and an edge from course v to course w if and only if v is a prerequisite for w. Find an algorithm that works directly with this graph representation, and computes the minimum number of semesters necessary to complete the curriculum (assume that a student can take any number of courses in one semester). The running time of your algorithm should be linear.

Perform depth-first search on each of the following graphs; whenever there’s a choice of vertices, pick the one that is alphabetically first. Classify each edge as a tree edge, forward edge, back edge, or cross edge, and give the pre and post number of each vertex.

Question:Undirected vs. directed connectivity.

(a) Prove that in any connected undirected graph G =(V , E)there is a vertexvV whose removal leaves G connected. (Hint: Consider the DFS search tree for G.)

(b) Give an example of a strongly connected directed graph G(V ,E)such that, for everyvV, removing v from G leaves a directed graph that is not strongly connected.

(c) In an undirected graph with two connected components it is always possible to make the graph connected by adding only one edge. Give an example of a directed graph with two strongly connected components 0 such that no addition of one edge can make the graph strongly connected.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free