(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
- Given 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_forwardPart a) only pleasearrow_forward
- A 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_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_forward
- Problem: A Hamiltonian cycle, also called a Hamiltonian circuit, Hamilton cycle, or Hamilton circuit, is a graph cycle (i.e., closed loop) through a graph that visits each node exactly once. A graph possessing a Hamiltonian cycle is said to be a Hamiltonian graph. An example to this is shown image: the task is to construct a Space State tree that shows the different solutions in generating a Hamiltonian cyclearrow_forwardGive an example of a graph that has all 3 of the following properties. (Note that you need to give a single graph as the answer.) (i) It is connected (ii) It has one articulation point. (iii) The graph needs at least 4 colors for a valid vertex coloring (iv) The graph does not have a 4-clique (that is, a clique of 4 vertices) as a subgraph.arrow_forward1 A spanning tree for an undirected graph is a sub-graph which includes all vertices but has no cycles. There can be several spanning trees for a graph. A weighted undirected graph can have several spanning trees One of the spanning trees has smallest sum of all the weights associated with the edges. This tree is called minimum spanning tree (MST). Find the MST in the following graph using Kruskal?s Algorithm. V={a, b, c, d, e, f, g, h, i, j} and E={(a, b, 12), (a, b, 3), (a, j, 13), (b, c, 12), (b, d, 2), (b, h, 4), (b, i, 25), (c, d, 7), (c, j, 5), (e, f, 11), (e, j, 9), (f, g, 15), (f, h, 14), (g, h, 6), (h, d, 20), (h, i, 1) }. Note: Numeric value is the weight of the corresponding edge.arrow_forward
- Problem 2 In a graph a Clique is a fully connected subgraph. An example of a clique is given below. I have an idea for a greedy algorithm to find the largest clique. First I start with a vertex v, then I grow the clique like we did with Prim's algo- rithm. We check each neighbor, and if it's connected to everything in our clique, then we add it to our clique. For the above graph I started with b, then added c, d, and e to my clique. Since a isn't connected the algorithm terminates. Is this a good idea for an algorithm? If it is, explain why it gives me the maximum clique, and give the running time. If not, then give an example where it would fail. OCarrow_forward3. Kleinberg, Jon. Algorithm Design (p. 519, q. 28) Consider this version of the Independent Set Problem. You are given an undirected graph G and an integer k. We will call a set of nodes I "strongly independent" if, for any two nodes v, u € I, the edge (v, u) is not present in G, and neither is there a path of two edges from u to v. That is, there is no node w such that both (v, w) and (u, w) are present. The Strongly Independent Set problem is to decide whether G has a strongly independent set of size at least k. Show that the Strongly Independent Set Problem is NP-Complete.arrow_forward(V, E) be an undirected graph. Assume that the vertices 2. Let G represent documents. The edges are weighted so that w(i, j) is the dissimilarity between documents i and j. It is desired to partition the vertices into k > 3 disjoint clusters such that k ΣΣ υ(u, υ). i=1 (u,v)EE u,vEC; is minimized. The set C; is the set of documents in cluster i. Show that the e-approximate version of this problem is P-hard for all e, e > 0. Note that k is a fixed integer provided with each problem instance and may be different for different instances.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