Either prove or give a counterexample: if {u,v}is an edge in an undirected graph, and during depth-first search (u)<post (v), then vis an ancestor of uin the DFS tree.

Short Answer

Expert verified

If {u,v} is an edge in an undirected graph, and during the depth-first search post (u) < post(v) , then v is an ancestor of u in the DFS tree.

Step by step solution

01

Depth-first search

Depth First Search (DFS) is an application of graph traversal. It traverses the node downwards and uses the stack as a data structure through this it traverses all vertices in the downward direction one by one.

Some properties ofdepth-first search are as follows:

  1. Using DFT we can verify whether the graph is connected or not it means it detects the cycle present in the graph or not.
  2. We can find out the number of connected components by using adepth-first search.
  3. Here we are using the stack as a data structure.

The time complexity of the list is O(V+E).

The time complexity of matrix isOV2.

It contains various edges, they aretree edge, forward edge, back edge, or cross edge all the edges are explained below:

Tree edge: The graph obtained by traversing while using a depth-first search is called its tree edge.

Forward edge: the edge {u,v} whereis a descendant and it is not part of the depth-first search is called the forward edge.

Back edge: the edge {u,v} where is the ancestor and it is not part of the depth-first search is called the back edge.

02

Step 2: During DFS,post (u) < (v) , and v is an ancestor of u in the DFS tree

Consider the depth first search tree of graph G starting at any vertex. For this graph, if depth-first search is performed in the graph then if post is less than post v than, here the edge {u,v} where u is ancestor and it is not part of depth first search is called back edge. If {u,v} is an edge in an undirected graph and while performing a depth-first search in the undirected connected graph the the post (u)< post (v) , then v is an ancestor of in the DFS tree.

Here it follows these two conditions:

  1. [preu,post u] [prev.post v ]
  2. [prev,[preu,post u]post v ]

Only these options are taking place here for an undirected graph post u is less than post v. since there is an edge between these two vertices and option one is not possible because it is a must to traverse all the neighbors of a vertex before marking it as visited.

So, option two’s condition is only possible which defines the vertex v is the ancestor of u. hence an undirected graph, and during the depth-first search, post(u) < post (v),then v is an ancestor of u in the depth-first search traversal.

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 for the following task.
Input: A directed acyclic graph G

Does G contain a directed path that touches every vertex exactly once?

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

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.

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.

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

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