Question

In: Computer Science

ive an example of a simple, undirected graph that has a single source shortestpath tree which...

ive an example of a simple, undirected graph that has a single source shortestpath tree which breadth-first search will not return for any ordering of its vertices.Your answer must

(a) Specify the graphG= (V, E)by specifying V and E.

(b) Specify the single source shortest path treeT= (V, ET) by specifying E T and also specifying the roots∈V.

(c) and include a clear explanation of why the breadth-first search algorithm we discussed in class will never produce T for any orderings of the vertices.

Solutions

Expert Solution

(a)An arbitrary vertex could lay closer to the ’center’ of the graph, hence the BFS depth will be underestimating the diameter. For example, in graph G = (V, E) = ({a, v, b}, {(a, v),(v, b)}), a BFS from v will have depth 1 but the graph has diameter 2

(b)

If the greatest number of edges on any shortest path from the source is m, then
the path-relaxation property tells us that after m iterations of BELLMANFORD, every vertex v has achieved its shortest-path weight in v.d. By the
upper-bound property, after m iterations, no d values will ever change. Therefore, no d values will change in the (m+ 1)st iteration. Because we do not know
m in advance, we cannot make the algorithm iterate exactly m times and then
terminate. But if we just make the algorithm stop when nothing changes any
more, it will stop after m + 1 iterations.
   BELLMAN−FORD−(M+1)(G, w, s )
   INITIALIZE−SINGLE−SOURCE(G, s )
   changes = TRUE

   while changes == TRUE
       changes = FALSE
       for each edge (u, v) ∈ G.E
           RELAX−M( u , v , w)
   RELAX−M( u , v ,w)
   if v.d > u.d+w(u,v)
v.d = u.d + w(u,v)
v.π = u
changes = TRUE
The test for a negative-weight cycle (based on there being a d value that
would change if another relaxation step was done) has been removed above,
because this version of the algorithm will never get out of the while loop unless
all d values stop changing

(c)

  • Every time we want to find what are the edges adjacent to a given node ‘U’, we have to traverse the whole array AdjacencyMatrix[U], which is of length |V|.
  • During BFS, you take a starting node S, which is at level 0. All the adjacent nodes are at level 1. Then, we mark all the adjacent nodes of all vertices at level 1, which don’t have a level, to level 2. So, every vertex will belong to one level only and when an element is in a level, we have to check once for its adjacent nodes which takes O(V) time. Since the level covers V elements over the course of BFS, the total time would beO(V * V) which is O(V2).
  • In short, for the case of Adjacency Matrix, to tell which nodes are adjacent to a given vertex, we take O(V) time, irrespective of edges.
  • Whereas, when Adjacency List is used, it is immediately available to us and it just takes time complexity proportional to adjacent nodes itself, which upon summation over all nodes V is E. So, BFS when using Adjacency List gives O(V + E).

Related Solutions

give an example of a simple, undirected, weighted graph such that breadth-firstsearch outputs a search-tree that...
give an example of a simple, undirected, weighted graph such that breadth-firstsearch outputs a search-tree that is not a single source shortest path tree. Youranswer must (a) Specify the graphG= (V, E)by specifyingVandE. (b) Specify the weight functionw. (c) Specify an ordering of the vertices and the search-tree output by breadth-first search assuming the specified graph and ordering. (d) Specify a valid single-source shortest path treeT= (V, ET)by specifyingETand its root, the first vertex in your specified ordering. (e) Include...
In a simple undirected graph H the sum of vertex degrees is 60. What is the...
In a simple undirected graph H the sum of vertex degrees is 60. What is the smallest possible number of vertices in this graph? What is the largest possible number of vertices in the graph?
Which graph search method will be better for finding a cycle in an undirected graph: a...
Which graph search method will be better for finding a cycle in an undirected graph: a BTS or a DFS? In detail, describe (create) an algorithm for finding a cycle in any undirected graph, explaining why the algorithm assures to find a cycle if there exists one.
Let G be a simple undirected graph with n vertices where n is an even number....
Let G be a simple undirected graph with n vertices where n is an even number. Prove that G contains a triangle if it has at least (n^2 / 4) + 1 edges using mathematical induction.
You are given an undirected graph G = ( V, E ) in which the edge...
You are given an undirected graph G = ( V, E ) in which the edge weights are highly restricted. In particular, each edge has a positive integer weight from 1 to W, where W is a constant (independent of the number of edges or vertices). Show that it is possible to compute the single-source shortest paths in such a graph in O(E+V) time.
Give an algorithm that constructs an undirected connected graph, which allows for labeling of the n...
Give an algorithm that constructs an undirected connected graph, which allows for labeling of the n vertices u - v <= k for every edge (u,v), where k is some constant. All nodes have a unique label.
Prove or disprove: If G = (V; E) is an undirected graph where every vertex has...
Prove or disprove: If G = (V; E) is an undirected graph where every vertex has degree at least 4 and u is in V , then there are at least 64 distinct paths in G that start at u.
Design a linear-time algorithm which, given an undirected graph G and a particular edge e in...
Design a linear-time algorithm which, given an undirected graph G and a particular edge e in it, determines whether G has a cycle containing e. Your algorithm should also return the length (number of edges) of the shortest cycle containing e, if one exists. Just give the algorithm, no proofs are necessary. Hint: you can use BFS to solve this.
which of the following is a net sugar source for a deciduous angiosperm tree? A. new...
which of the following is a net sugar source for a deciduous angiosperm tree? A. new leaves in early spring B. fruits in summer C. roots in early spring D. roots in early autumn Which type of mutant would be most likely to produce a bushier phenotype? A. strigolactone underproducer B. auxin overproducer C. cytokinin underproducer D. strigolactone overproducer E. gibberellin overproducer Which of the following observations provides the strongest evidence against root pressure being the principal mechanism of water...
Consider an undirected graph G that has n distinct vertices. Assume n≥3. How many distinct edges...
Consider an undirected graph G that has n distinct vertices. Assume n≥3. How many distinct edges will there be in any circuit for G that contains all the vertices in G? What is the maximum degree that any vertex in G can have? What is the maximum number of distinct edges G can have? What is the maximum number of distinct edges that G can have if G is disconnected?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT