/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q17E Infinite paths.聽Let G=(V,E)聽 b... [FREE SOLUTION] | 91影视

91影视

Infinite paths.Let G=(V,E) be a directed graph with a designated 鈥渟tart vertex鈥 sV,asetVGV, a set of 鈥済ood鈥 vertices, and a set VBV of 鈥渂ad鈥 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 鈥渟tart vertex鈥 sV, a set localid="1659074912703" VG=Vof 鈥済ood鈥 vertices, and a set VB=Vof 鈥渂ad鈥 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 鈥渟tart vertex鈥 sV, a set role="math" localid="1659075365201" VG=Vof 鈥済ood鈥 vertices, and a set VB=Vof 鈥渂ad鈥 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 鈥渟tart vertex鈥 sV, a set VG=Vof 鈥済ood鈥 vertices, and a set role="math" localid="1659075463049" VB=Vof 鈥渂ad鈥 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 鈥渟tart vertex鈥 sV, a set VGVof 鈥済ood鈥 vertices, and a set VBVof 鈥渂ad鈥 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 91影视!

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.

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 鈥渕etagraph鈥 (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

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.

The reverse of a directed graph G = (V,E) is another directed graphGR=(V,ER) on the same vertex set, but with all edges reversed that is,ER={(v,u):(u,v)E} . Give a linear-time algorithm for computing the reverse of a graph in adjacency list format.

Run the DFS-based topological ordering algorithm on the following graph. Whenever you have a choice of vertices to explore, always pick the one that is alphabetically first.

(a) Indicate the pre and post numbers of the nodes.

(b) What are the sources and sinks of the graph?

(c) What topological ordering is found by the algorithm?

(d) How many topological orderings does this graph have?

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.