Give an efficient algorithm which takes as input a directed graph G(V,E)and determines whether or not there is a vertexsV from which all other vertices are reachable.

Short Answer

Expert verified

Algorithm takes as input a directed graph G(V,E) and determines whether or not there is a vertexsVfrom which all other vertices are reachable is proved.

Step by step solution

01

Explain the algorithm for determining a vertex s∈V from which all the vertices are reachable.

A vertex s belongs to G(V,E) where v is the vertex and e is the edges such that all other vertices are reachable from the vertex s and this vertex s is known as mother vertex. And there may be more than one mother vertex present in the graph.

In other words, it states that all other vertices in G are reached by a path from v. Kosaraju's algorithm is used to find strongly connected component in the graph.

02

Determine the mother vertex.

In an undirected graph, here all vertices are act as a mother vertex because from each vertex makes their path towards its every other vertex.

Or to finding the mother vertex in any directed graph here, check all vertices of the given graph and detect from which vertex every other node are connected.

Let a directed graph which contain nine edges and seven vertices. In this graph node 5 is act as a mother vertex from which all other vertices are reachable. For example, the graph is given below:

5is the mother vertex in directed graph.

Here in this graph from vertex five all other vertices are reachable. From 52by one vertex in the middle that is 2. From54by follow the directions from 564.

From 53by following the path that is56413there is the direct path from 52and at the last from 51path is 5601.

03

 A directed graph with mother vertices.

Another example is given as the directed graph which contain five edges and five vertices 0,1,2,3,4,5. In this graph node 0, 1 and 2 are act as a mother vertex from which all other vertices are reachable.

From vertices 0,1,2, all other vertices are reachable. From 0 to 1, consider 2 as a middle vertex. Like that from zero all the other vertices are visited. Then from 1 to 3, consider 0 as a middle vertex. Like that from 0, all the other vertices are reachable same as by the mother node 2.

Hence,thealgorithm that determines whether or not there is a vertexsVfrom which all other vertices are reachable is proved.

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

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.

Give a linear-time algorithm to find an odd-length cycle in a directed graph. (Hint: First solve this problem under the assumption that the graph is strongly connected.)

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?

Let S be a finite set. A binary relation on S is simply a collection R of ordered pairs(x,y)S×S. . For instance, S might be a set of people, and each such pair (x,y)R might mean “ x knows y ”.

An equivalence relationis a binary relation which satisfies three properties:

  • Reflexivity: localid="1659006645990" (x,y)R for all XS
  • Symmetry: If (x,y)R then (y,x)R
  • Transitivity: if (x,y)R and (y,z)R then localid="1659006784500" (x,Z)R

For instance, the binary relation “has the same birthday as” is an equivalence relation, whereas “is the father of” is not, since it violates all three properties.

Show that an equivalence relation partition set S into disjoint groups S1,S2,,Sk (in other words, S=S1S2SkandSiSj=ϕforallij ) such that:

  • Any two members of a group are related, that is, (x,y)R for any localid="1659006702579" (x,y)Si, for any i .
  • Members of different groups are not related, that is, for all ij, for all localid="1659006762355" xSi andySi, we have (x,Z)R.

(Hint: Represent an equivalence relation by an undirected graph.)

Infinite paths.Let G=(V,E) be a directed graph with a designated “start vertex” sV,asetVGV, a set of “good” vertices, and a set VBV of “bad” vertices. An infinite trace of is an infinite sequence of vertices viV such that (1)v0=s, and (2) for all i0, (vi,vi+1)E. That is, p is an infinite path in G starting at vertex s. Since the setV of vertices is finite, every infinite trace of Gmust visit some vertices infinitely often.

  1. If p is an infinite trace, let Inf(p)V be the set of vertices that occur infinitely often in p. Show that Inf(p) is a subset of a strongly connected component of G.
  2. Describe an algorithm that determines if role="math" G has an infinite trace.
  3. Describe an algorithm that determines if G has an infinite trace that visits some good vertex in VG infinitely often.
  4. Describe an algorithm that determines if role="math" localid="1659627728759" G has an infinite trace that visits some good vertex in VG infinitely often, but visits no bad vertex in VB infinitely often.
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