Question A:
part I. Shortest path's length from S to T is 8. There two
roads with sum of 8: S->A->D->T and S->F->T.
part II. If we sue adjacenty list to
represent graph than worst time for Dijskstra is O(E + VlogV). If
we use matrix to represent graph than it is O(V^2 +ElogV).
part III. Distance will be length of 16. Ands
there will be same roads as in first part of question.
Question B:
multiplying each node by same number will not change shortest path.
Each path's length in graph will became A*B where A is the prevous
length and B is the number we use to multiply edges.
Questions C:
No, roads will not be same, because adding 2 to each edge affects
roads differently. For example if one road had 2 edges it will be
increased by 4, while another road with 3 edges will be increased
by 6. So the shortest path might not stay same,
Comment down for any queries
Please give a thumb up
a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps...
Consider the problem of finding the shortest paths in a weighted directed graph using Dijkstra's algorithm. Denote the set of vertices as V, the number of vertices as |V|, the set of edges as E, and the number of edges as |E|. Answer the following questions.Below is a pseudo-code of the algorithm that computes the length c[v] of the shortest path from the start node s to each node v. Answer code to fill in the blank _______ .
5. (10 pts) Give a concrete example of a directed and weighted graph G and two vertices u and v, where the Dijkstra's algorithm does not find the shortest path from u to v in G but the Bellman-Ford algorithm does. Obviously such a graph must have at least one negative- weight edge.
Consider the following weighted, directed graph G. There are 7 vertices and 10 edges. The edge list E is as follows:The Bellman-Ford algorithm makes |V|-1 = 7-1 = 6 passes through the edge list E. Each pass relaxes the edges in the order they appear in the edge list. As with Dijkstra's algorithm, we record the current best known cost D[V] to reach each vertex V from the start vertex S. Initially D[A]=0 and D[V]=+oo for all the other vertices...
5. Here are the vertices and edges of directed graph G: V= {2.6.c.de.f} E= {ab, ac, af ca. bc. be.bf. cd, ce, de, df). Weights: w(ab) = 2 w(ac) = 5, w(af) = 10, w(ca) = 2. w(be) = 2. w(be) = 10, w(bf) = 11. w(cd)= 9. w(ce) = 7. w(de) = 2. w(df) = 2. a. Draw the Graph. This is a directed, weighted graph so you need to include arrows and weights. You can insert a pic...
10) Shortest Paths (10 marks) Some pseudocode for the shortest path problem is given below. When DIJKSTRA (G, w,s) is called, G is a given graph, w contains the weights for edges in G, and s is a starting vertex DIJKSTRA (G, w, s) INITIALIZE-SINGLE-SOURCE(G, s) 1: RELAX (u, v, w) 1: if dlv] > dlu (u, v) then 2d[v] <- d[u] +w(u, v) 3 4: end if 4: while Q φ do 5: uExTRACT-MIN Q) for each vertex v...
Given a directed graph with positive edge lengths and a specified vertex v in the graph, the "all-pairs" v-constrained shortest path problem" is the problem of computing for each pair of vertices i and j the shortest path from i to j that goes through the vertex v. If no such path exists, the answer is . Describe an algorithm that takes a graph G= (V; E) and vertex v as input parameters and computes values L(i; j) that represent...
Shortest paths Consider a directed graph with vertices fa, b, c, d, e, f and adjacency list representation belovw (with edge weights in parentheses): a: b(4), f(2) e: a(6), b(3), d(7) d: a(6), e(2) e: d(5) f: d(2), e(3) (i) Find three shortest paths from c to e. (ii) Which of these paths could have been found by Dijkstra's shortest path algorithm? (Give a convincing explanation by referring to the main steps of the algorithm.)
10. You are given a directed graph G(V, E) where every vertex vi E V is associated with a weight wi> 0. The length of a path is the sum of weights of all vertices along this path. Given s,t e V, suggest an O((n+ m) log n) time algorithm for finding the shortest path m s toO As usual, n = IVI and m = IEI.
Let G = (V, E, w) be a connected weighted undirected graph. Given a vertex s ∈ V and a shortest path tree Ts with respect to the source s, design a linear time algorithm for checking whether the shortest path tree Ts is correct or not.(C pseudo)
3. (15 pts) The diameter of a graph is the largest of all shortest-path distances in the graph. In other words, if So(x, y) is the length of the shortest path from| x to y in graph G = (V,E), then the diameter of G is max (Sc(t,y)J Give an algorithm to compute the diameter of an undirected graph G (V. E), with running time at lnost O (V12 + VİİE). Include an analysis of the running time. 3. (15...