(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
- Part 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_forwardGiven a graph that is a tree (connected and acyclic). (1) Pick any vertex v. (II) Compute the shortest path from v to every other vertex. Let w be the vertex with the largest shortest path distance. (III) Compute the shortest path from w to every other vertex. Let x be the vertex with the largest shortest path distance. Consider the path p from w to x. Which of the following are true a. p is the longest path in the graph b. p is the shortest path in the graph c. p can be calculated in time linear in the number of edges/vertices a,c a,b a,b,c b.carrow_forwardIn Computer Science a Graph is represented using an adjacency matrix. Ismatrix is a square matrix whose dimension is the total number of vertices.The following example shows the graphical representation of a graph with 5 vertices, its matrixof adjacency, degree of entry and exit of each vertex, that is, the total number ofarrows that enter or leave each vertex (verify in the image) and the loops of the graph, that issay the vertices that connect with themselvesTo program it, use Object Oriented Programming concepts (Classes, objects, attributes, methods), it can be in Java or in Python.-Declare a constant V with value 5-Declare a variable called Graph that is a VxV matrix of integers-Define a MENU procedure with the following textGRAPHS1. Create Graph2.Show Graph3. Adjacency between pairs4.Input degree5.Output degree6.Loops0.exit-Validate MENU so that it receives only valid options (from 0 to 6), otherwise send an error message and repeat the reading-Make the MENU call in the main…arrow_forward
- 3) The graph k-coloring problem is stated as follows: Given an undirected graph G= (V,E) with N vertices and M edges and an integer k. Assign to each vertex v in V a color c(v) such that 1arrow_forward3) The graph k-coloring problem is stated as follows: Given an undirected graph G = (V,E) with N vertices and M edges and an integer k. Assign to each vertex v in Va color c(v) such that 1< c(v)arrow_forwardA path of length two is denoted by P2. If a graph G does not contain P2 as induced subgraph, then: 1) All vertices must be adjacent to each other. 2) The graph must be connected. 3) There must be an edge between every pair of vertices. 4) Every vertex must have degree n-1, where n is the number of vertices in the graph.arrow_forward(1) T F Given a directed graph G and a vertex v in the graph, breath first search (BFS) can be used to detect if v is part of a cycle in the graph. (2) T F Let P be a shortest path from some vertex s to some other vertex t in a directed graph. If the weight of each edge in the graph is decreased by one, then P will still be a shortest path from s to t. (3) T F edge Kruskal's algorithm is always correct even in graphs with negative weights. (4) T F For any flow network, there is only one unique way to assign flow value to the edges so as to achieve the maximum flow for the network. NP problems are those problems that cannot be solved in polynomial (5) T F time.arrow_forwardIs it true or false? If it is true, include a (short, but clear) argument why it is true, and if it is false, include a concrete graph which shows that the claim is false.a) If all vertices in a connected graph have even degree, then for whichever two vertices u and v in the graph you choose, there is an Eulerian trail between u and v. b) Given a graph G we construct a new graph H by adding a new vertex v and edges between v and every vertex of G. If G is Hamiltonian, then so is H.c) We know that if a graph has a walk between u and v it also has a path between u and v, for any two vertices u and v. Is it always true that if a graph has a circuit containing u and v it also has a cycle containing u and v? d) The complete bipartite graph K?,?(lowered indicies) is Hamiltonian if and only if m = n ≥ 2.arrow_forwardBe G=(V, E)a connected graph and u, vEV. The distance Come in u and v, denoted by d(u, v), is the length of the shortest path between u'and v, Meanwhile he width from G, denoted as A(G), is the greatest distance between two of its vertices. a) Show that if A(G) 24 then A(G) <2. b) Show that if G has a cut vertex and A(G) = 2, then Ġhas a vertex with no neighbors.arrow_forward3. From the graph above determine the vertex sequence of the shortest path connecting the following pairs of vertex and give each length: a. V & W b. U & Y c. U & X d. S & V e. S & Z 4. For each pair of vertex in no. 3 give the vertex sequence of the longest path connecting them that repeat no edges. Is there a longest path connecting them?arrow_forwardAn Euler path, in a graph or multigraph, is a walk through the graph which uses every edge exactly once. An Euler circuit is an Euler path which starts and stops at the same vertex. NOTE: graphs are in the image attached. Which of the graphs below have Euler paths? Which have Euler circuits? List the degrees of each vertex of the graphs above. Is there a connection between degrees and the existence of Euler paths and circuits? Is it possible for a graph with a degree 1 vertex to have an Euler circuit? If so, draw one. If not, explain why not. What about an Euler path? What if every vertex of the graph has degree 2. Is there an Euler path? An Euler circuit? Draw some graphs. Below is part of a graph. Even though you can only see some of the vertices, can you deduce whether the graph will have an Euler path or circuit? NOTE: graphs is in the image attached.arrow_forwardA. Consider the following graphs: X w U Graph A Graph Barrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended textbooks for you
- 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
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:PEARSONC 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