(a)
To prove the breath first search properties in an undirected graph.
(a)
Explanation of Solution
In the undirected graph, breath first search follow properties as:
Suppose in the undirected graph an edge ( u , v ) is consider as forward or back edge then vertex ‘ u’ should occur before vertex ‘ v’ and edges associated with ‘ u’ should be explore before any other edge in breath first search. Thus, the edge ( u , v ) can be considered as the tree edge because there is no forward and backward edge in undirected graph BFS traversal.
In the breath first search, an edge must be a tree if
Therefore for every tree edge ( u, v ) in breath first search,
If vertex ‘ u’ visit before vertex ‘ v’ , and edge ( u, v ) is cross edge. As the properties of tree edge and cross edge, vertex ‘ u’ visit before vertex ‘ v’ that means vertex ‘ v’ must be in the queue. Hence, from the given statement, it will follow the condition for the cross edge ( u, v ):
Therefore,
(b)
To prove the breath first search properties in the directed graph.
(b)
Explanation of Solution
Breath first search properties in the directed graph as follows:
An edge ( u, v ) is not the tree edge if the given graph G is directed. So, the graph will not contain the forward edge ( u, v ).
In the breath first search, an edge must be a tree if
If vertex ‘ u’ visit before vertex ‘ v’ , and edge ( u, v ) is cross edge. As the properties of tree edge and cross edge, vertex ‘ u’ visit before vertex ‘ v’ that means vertex ‘ v’ must be in the queue. Hence, from the given statement, it will follow the condition for the cross edge ( u, v ):
Therefore,
By seeing the above statements, it is clear for all vertices,
In the breath first search, back edge (u, v) where vertex ‘v’ is the ancestor of vertex ‘u’ and from the given vertices if the drawn edge is larger than the other. Hence,
Therefore, for every back edge (u, v),
Want to see more full solutions like this?
Chapter 22 Solutions
Introduction to Algorithms
- Let G be a graph with n vertices. The k-coloring problem is to decide whether the vertices of G can be labeled from the set {1, 2, ..., k} such that for every edge (v,w) in the graph, the labels of v and w are different. Is the (n-4)-coloring problem in P or in NP? Give a formal proof for your answer. A 'Yes' or 'No' answer is not sufficient to get a non-zero mark on this question.arrow_forwardComputer Science In a triangle graph, the spanning-tree-doubling approximation to the TSP (in the version described in class for finding a walk that touches every vertex at least once, without shortcuts) will always produce a four-edge walk, even for inputs where there is a shorter three-edge cycle. Find weights for the edges of this graph for which the ratio of (solution found by the approximation)/(optimal solution) is as large as possible. What is this ratio for your weights?arrow_forwardGiven a vertex set W = {1, 2, 3, 4}, solve for the following questions: (i) Knowing that edges are the same if and only if they have the same endpoint, how many different edges are possible? (ii) Suppose for this question that graphs are different if they have different sets of edges (they do not depend on if the graphs are isomorphic or not). How many simple graphs are there with the vertex set W? (iii) Draw the eleven nonisomorphic simple graphs that have four vertices.arrow_forward
- A graph is biconnected if every pair of vertices is connectedby two disjoint paths. An articulation point in a connected graph is a vertex that woulddisconnect the graph if it (and its adjacent edges) were removed. Prove that any graphwith no articulation points is biconnected. Hint : Given a pair of vertices s and t and apath connecting them, use the fact that none of the vertices on the path are articulationpoints to construct two disjoint paths connecting s and t.arrow_forwardRaw Blame Given an undirected, connected and weighted graph G(V, E) with V number of vertices (which are numbered from 0 to V-1) and E number of edges. Find and print the Minimum Spanning Tree (MST) using Kruskal's algorithm. For printing MST follow the steps - 1. In one line, print an edge which is part of MST in the format - v1 v2 w where, v1 and v2 are the vertices of the edge which is included in MST and whose weight is w. And v1 <= v2 i.e. print the smaller vertex first while printing an edge. 2. Print V-1 edges in above format in different lines. Note : Order of different edges doesn't matter. Input Format : Line 1: Two Integers V and E (separated by space) Next E lines : Three integers ei, ej and wi, denoting that there exists an edge between vertex ei and vertex ej with weight wi (separated by space) Output Format : Print the MST, as described in the task. Constraints : 2 <= V, E <= 10^5 Time…arrow_forwardWhat is the largest and what is the smallest number of distinct solutions the maximum-cardinality-matching problem can have for a bipartite graph G = <V, U, E> with n vertices in each vertex set V and U and at least n edges?arrow_forward
- For each pair of graphs G1 = <V1, E1> and G2 = <V2, E2> a) determine if they are isomorphic or not. b) Determine a function that can be isomorphic between them if they are isomorphic. Otherwise you should justify why they are not isomorphic. c) is there an Euler road or an Euler bike in anyone graph? Is Hamilton available? You should draw if the answer is yes and reason if your answer is no.arrow_forwardplease answer both of the questions. 7. The Bellman-Ford algorithm for single-source shortest paths on a graph G(V,E) as discussed in class has a running time of O|V |3, where |V | is the number of vertices in the given graph. However, when the graph is sparse (i.e., |E| << |V |2), then this running time can be improved to O(|V ||E|). Describe how how this can be done.. 8. Let G(V,E) be an undirected graph such that each vertex has an even degree. Design an O(|V |+ |E|) time algorithm to direct the edges of G such that, for each vertex, the outdegree is equal to the indegree. Please give proper explanation and typed answer only.arrow_forwardFirst, convert this labelled directed graph into a search tree representation. Next, you need to define your heuristic function for each node. Later, find the searching space from the Main Gate (start) to the Varsity Mall (goal) for the following search methods:a) Depth-First Searchb) Breadth-First Searchc) Depth Limited Search (L = 3)d) Uniform Cost Searche) Best First (Greedy) Searchf) A* Algorithmarrow_forward
- Recall the Clique problem: given a graph G and a value k, check whether G has a set S of k vertices that's a clique. A clique is a subset of vertices S such that for all u, v € S, uv is an edge of G. The goal of this problem is to establish the NP-hardness of Clique by reducing VertexCover, which is itself an NP-hard problem, to Clique. Recall that a vertex cover is a set of vertices S such that every edge uv has at least one endpoint (u or v) in S, and the VertexCover problem is given a graph H and a value 1, check whether H has a vertex cover of size at most 1. Note that all these problems are already phrased as decision problems, and you only need to show the NP-Hardness of Clique. In other words, we will only solve the reduction part in this problem, and you DO NOT need to show that Clique is in NP. Q4.1 Let S be a subset of vertices in G, and let C be the complement graph of G (where uv is an edge in C if and only if uv is not an edge in G). Prove that for any subset of vertices…arrow_forwardGiven a DAG and two vertices v and w, find the lowest commonancestor (LCA) of v and w. The LCA of v and w is an ancestor of v and w that has nodescendants that are also ancestors of v and w. Computing the LCA is useful in multipleinheritance in programming languages, analysis of genealogical data (find degree ofinbreeding in a pedigree graph), and other applications. Hint : Define the height of avertex v in a DAG to be the length of the longest path from a root to v. Among verticesthat are ancestors of both v and w, the one with the greatest height is an LCA of v and w.arrow_forwardPart 2: Random GraphsA tournament T is a complete graph whose edges are all oriented. Given a completegraph on n vertices Kn, we can generate a random tournament by orienting each edgewith probability 12 in each direction.Recall that a Hamiltonian path is a path that visits every vertex exactly once. AHamiltonian path in a directed graph is a path that follows the orientations of thedirected edges (arcs) and visits every vertex exactly once. Some directed graphs havemany Hamiltonian paths.In this part, we give a probabilistic proof of the following theorem:Theorem 1. There is a tournament on n vertices with at least n!2n−1 Hamiltonian paths.For the set up, we will consider a complete graph Kn on n vertices and randomlyorient the edges as described above. A permutation i1i2 ...in of 1,2,...,n representsthe path i1 −i2 −···−in in Kn. We can make the path oriented by flipping a coin andorienting each edge left or right: i1 ←i2 →i3 ←···→in.(a) How many permutations of the vertices…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education