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.

Short Answer

Expert verified

a. All nodes in inf (p) are visited infinite times, thus inf (p) is a subset of a strongly connected component of G .

b. An algorithm:

Input: G = (V, E)

Procedure: inf (p)

p= V [i]

v0=s

for i = 0, i0, i+1

if vi,vi+1E

return Infp

print G has an infinite trace.

c. Algorithm:


Input: G = (V, E)

Procedure: Inf (p)

good_vertices=VGvbad_vertices=VBvp=viv0=sfori=0,i0,i+1ifvi,vi+1Eifvi+1VGreturnInfp

print has an infinite trace that visits good vertices.

d. Algorithm:

Input: G = (V, E)

Procedure: Inf (p)

good_vertices=VGvbad_vertices=VBvp=Viv0=sfori=0,i0,i+1ifvi,vi+1Eifvi,vi+1VBreturnInf(p)

print G has an infinite trace that visits good vertices has no bad vertices.

Step by step solution

01

Explain Infinite paths.

An infinite trace p of G is an infinite sequence v0v1v2Kof vertices such that v0=s, and for all i0,(vi,vi+1)E, .

02

Show that lnf (p) is a subset of a strongly connected component of G .

(a)

Consider the directed graph G=(V,E) with a designated “start vertex” sV, a set localid="1659074912703" VG=Vof “good” vertices, and a set VB=Vof “bad” vertices. That is, p is an infinite path in G starting at vertex s . Since the set Vof vertices is finite, every infinite trace of Gmust visit some vertices infinitely often.

All nodes in Inf ( p ) are visited infinite times, thus Inf ( p ) is a subset of a strongly connected component of G .

Therefore, It has been shown that Inf ( p ) is a subset of a strongly connected component of G .

03

Describe an algorithm that determines if G has an infinite trace.

(b)

Consider the directed graph G=(V,E)with a designated “start vertex” sV, a set role="math" localid="1659075365201" VG=Vof “good” vertices, and a set VB=Vof “bad” vertices.

An algorithm that determines if G has an infinite trace.

Input:(V,E)procedure:Inf(p)p=viv0=sfori=0,i0,i+1ifvi,vi+1EreturnInf(p)printGhasaninfinitetrace.

The above algorithm determines if the given graph has an infinite trace by checking the edges and vertices of the graph.

Therefore, An algorithm has be describes to determine if G has an infinite trace.

04

Describe an algorithm that determines if G has an infinite trace that visit good vertices

(c)

Consider the directed graph G = ( V,E ) with a designated “start vertex” sV, a set VG=Vof “good” vertices, and a set role="math" localid="1659075463049" VB=Vof “bad” vertices.

An algorithm that determines if G has an infinite trace.

Input:G=(V,E)Procedure:Inf(p)good_vertices=VGvbad_vertices=VBvp=viv0=sfori=0,i0,i+1ifvi,vi+1Eifvi+1VGreturninf(p)printGhasaninfinitetracethatvisitsgoodvertices.

The above algorithm determines if the given graph has an infinite trace that visits good vertices often by checking the edges and good vertices of the graph.

Therefore, An algorithm has be describes to determine if G has an infinite trace that often visits good vertices.

05

Describe an algorithm that determines if G has an infinite trace that visit no bad vertices

(d)

Consider the directed graph G = (V,E) with a designated “start vertex” sV, a set VGVof “good” vertices, and a set VBVof “bad” vertices.

An algorithm that determines if G has an infinite trace.

Input:G=(V,E)Procedure:Inf(p)good_vertices=VGvbad_vertices=VBvp=vivG=sfori=0,i0,i+1ifv1,vi+1Eifvi+1VGifvi+1VBreturnInf(p)printGhasaninfinitetracethatvisitsgoodverticeshasnobadvertices.

The above algorithm determines if the given graph has an infinite trace that visits good vertices often by checking the edges and bad vertices of the graph.

Therefore, An algorithm has be describes to determine if G has an infinite trace that often visits good vertices and no bad vertices.

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 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 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.

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.)

You are given tree T=(V,E) along with a designated root node rV. The parent of any node Vr, denoted p(V), is defined to be the node adjacent to v in the path from r to v . By convention, p(r)=r. For k>1, define pk(v)pk-1(pv)andp1(v)=p(v)(so pk(v)is the k th ancestor of v ). Each vertex v of the tree has an associated non-negative integer label l(v). Given a linear-time algorithm to update the labels of all the vertices T according to the following rule: lnew(v)=l(plvv).

On page 102, we defined the binary relation “connected” on the set of vertices of a directedgraph. Show that this is an equivalence relation(see Exercise 3.29), and conclude that it partitions the vertices into disjoint strongly connected components.

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