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

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

In an undirected graph, the degreed(u) of a vertex u is the number of neighbours u is the number of neighbors u has, or equivalently, the number of edges incident upon it. In a directed graph, we distinguish between the indegreedin(u), which is the number of edges into u, and the outdegreedout(u), the number of the edges leaving u.

(a) Show that in an undirected graph, role="math" localid="1658908755010" uevd(u)=2|E|

(b) Use part (a) to show that in an undirected graph, there must be an even number of vertices whose degree is odd.

(c) Does a similar statement hold for the number of vertices with odd indegree in a directed graph?

For each node in an undirected graph, let twodegreeube the sum of the degrees of’s neighbors. Show how to compute the entire array of two degree. values in linear time, given a graph in adjacency list format

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

In the 2SAT problem, you are given a set of clauses, where each clause is the disjunction (OR) of two literals (a literal is a Boolean variable of or the negation of a Boolean variable). You are looking for a way to assign a valuetrueorfalseto each of the variables so that all clauses are satisfied- that is, there is at least one true literal in each clause. For example, here’s an instance of 2SAT:

x1x2¯x1¯x3¯x1x2x3¯x4x1¯x4

This instance has a satisfying assignment: set x1,x2,x3, and x4 totrue, false, false,andtrue,respectively.

  1. Are there other satisfying truth assignments of this 2SAT formula? If so, find them all.
  2. Give an instance of 2SAT with four variables, and with no satisfying assignment.

The purpose of this problem is to lead you to a way of solving 2SAT efficiently by reducing it to the problem of finding the strongly connected components of a directed graph. Given an instance l of 2SAT with n variables and m clauses, construct a directed graph GI=V,E as follows.

  • GIhas 2nnodes, one for each variable and its negation.
  • GIhas 2m edges: for each clause αβof l (where α,βare literals), G1has an edge from the negation of α to β, and one from the negation ofβ to α.

Note that the clause αβis equivalent to either of the implications α¯β or β¯α. In this sense, data-custom-editor="chemistry" GI records all implications in l .

(C). Carry out this construction for the instance of 2SAT given above, and for the instance you constructed in (b).

(d). Show that if GI has a strongly connected component containing both x and X¯ for some variable x , then l has no satisfying assignment.

(e). Now show the converse of (d): namely, that if none of GI’s strongly connected components contain both a literal and its negation, then the instance l must be satisfiable.(Hint: Assign values to the variables as follows: repeatedly pick a sink strongly connected component of GI. Assign valuetrueto all literals in the sink, assignfalseto their negations, and delete all of these. Show that this ends up discovering a satisfying assignment.)

(f). Conclude that there is a linear-time algorithm for solving 2SAT.

As in the previous problem, you are given a binary tree T=(V,E) with designated root node. In addition, there is an array x[.]with a value for each node in V Define a new array z[.]as follows: for each uV,

z[u]=the maximum of the x-values associated with u’s descendants.

Give a linear-time algorithm that calculates the entire z-array.

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