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

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.

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

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.

You are given a directed graph in which each nodeuV, has an associated pricepu which is a positive integer. Define the array cost as follows: for each uV,

cost[u] = price of the cheapest node reachable fromu (includingu itself).

For instance, in the graph below (with prices shown for each vertex), the cost values of the nodes A,B,C,D,E,Fare2,1,4,1,4,5,respectively.

Your goal is to design an algorithm that fills in the entire cost array (i.e., for all vertices).

(a) Give a linear-time algorithm that works for directed acyclic graphs.

(b) Extend this to a linear-time algorithm that works for all directed graphs.

Biconnected componentsLet G=(V,E) be an undirected graph. For any two edgese,e'E,, we’ll saye:e'if eithere=e'or there is a (simple) cycle containing both e and e'.

a. Show that : is an equivalence relation (recall Exercise 3.29) on the edges.

The equivalence classes into which this relation partitions the edges are called the biconnected components of G . A bridge is an edge which is in a biconnected component all by itself.

A separating vertexis a vertex whose removal disconnects the graph.

b. Partition the edges of the graph below into biconnected components, and identify the bridges and separating vertices.

Not only do biconnected components partition the edges of the graph, they almost partition the vertices in the following sense.

c. Associate with each biconnected component all the vertices that are endpoints of its edges. Show that the vertices corresponding to two different biconnected components are either disjoint or intersect in a single separating vertex.

d. Collapse each biconnected component into a single meta-node, and retain individual nodes for each separating vertex. (So there are edges between each component node and its separating vertices.) Show that the resulting graph is a tree.

DFS can be used to identify the biconnected components, bridges, and separating vertices of a graph in linear time.

e. Show that the root of the DFS tree is a separating vertex if and only if it has more than one child in the tree.

f. Show that a non-root vertex v of the DFS tree is a separating vertex if and only if it has a child v' none of whose descendants (including itself) has a back edge to a proper ancestor of v .

g. For each vertex u define:

Iowu=minpreuprew

Where (v,w) is a back edge for some descendant v of u.

(h) Show how to compute all separating vertices, bridges, and biconnected components of a graph in linear time.

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