Question

3. Let G=(V.E) be a weighted, directed graph with weight function w: E->{0,1,...,W} for some nonnegative integer W. Modify Di

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dijkstra’s algorithm proceeds as follows:

  1. While Q is not empty, remove the node v which is not already in S from Q with the least distance(v). Initially assign the s to empty or 0.
  2. Whenever a node gets visited add the node v to S
  3. Now update the distance values of adjacent nodes of the node v and for each new adjacent node u.
  4. Check if distance(v) + weight (u,y) < distance(u), if found, update the new minimum distance value u.
  5. If not found then no update and run the loop again until it terminates or if it has visited all the nodes

Dijkstra’s running time depends on the execution of the min-priority queue or the data structure used. The vertices which are closer to the source gets processed first. Each vertex or node will have a weight W assigned with it. The maximum value of the longest path of any graph would be (v-1)W. Now we can assign or process the vertices on the queue or get a string based on the distance values of the nodes, generally distance(v) will give the shortest route from the start to any vertex v.

Consider the queue has (v-1)W buckets, with that the node v can be extracted from the bucket d[v]. Starting from the source till the vertex v, each will have a value between 1 and (v-1)W. We can say that nodes can be found in buckets 1 …….. (v-1)W. We initialized the start as 0 so S can be found in bucket[0]. So subsequently this step will proceed until we have discovered all the nodes. Lets say now we have all buckets from bucket[0] tp bucket[(v-1)W]. So now once all the nodes are initialized with the buckets we now traverse the buckets, whenever a non-empty bucket is got, the first vertex will be removed and all adjacent nodes will be reset. So we will be proceeding this way till we reach the end of the queue or the data structure used. In a way, one can say now the executions are till O(WV) and in all this computations we are traversing through E edges, because the vertices or nodes are connected via edges, hence the total running time would ne O(WV + E), so the algo would look be as follows

D(G,W,S)

a. Initialize the source or start (G,S)

b. Initialize S to empty, S <-- { }

c. Initialize Q as : Q <-- V[G]

d. Run a while loop

while Q!={ } (run as long as Q is not equals to empty)

i. u <-- get min(Q)

ii. S <-- S U {u}

iii. For each vertex v  € adj[u]

            reset(u,v,w)

Add a comment
Know the answer?
Add Answer to:
3. Let G=(V.E) be a weighted, directed graph with weight function w: E->{0,1,...,W} for some nonnegative...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the problem of finding the shortest paths in a weighted directed graph using Dijkstra's algorithm.

    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...

    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.

  • a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps...

    a. (15 marks) i (7 marks) Consider the weighted directed graph below. Carry out the steps of Dijkstra's shortest path algorithm as covered in lectures, starting at vertex S. Consequently give the shortest path from S to vertex T and its length 6 A 2 3 4 S T F ii (2 marks) For a graph G = (V, E), what is the worst-case time complexity of the version of Dijkstra's shortest path algorithm examined in lectures? (Your answer should...

  • Problem #1 Let a "path" on a weighted graph G = (V,E,W) be defined as a...

    Problem #1 Let a "path" on a weighted graph G = (V,E,W) be defined as a sequence of distinct vertices V-(vi,v2, ,%)-V connected by a sequence of edges {(vi, t), (Ug, ta), , (4-1,Un)) : We say that (V, E) is a path from tovn. Sketch a graph with 10 vertices and a path consisting of 5 vertices and four edges. Formulate a binary integer program that could be used to find the path of least total weight from one...

  • 10. You are given a directed graph G(V, E) where every vertex vi E V is...

    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.

  • The below question refers to shortest paths trees in weighted, directed graphs. Read the following carefully....

    The below question refers to shortest paths trees in weighted, directed graphs. Read the following carefully. Assume that No two edges have the same weight There are no cycles of net negative weight. There are no self-edges (edges leading from a vertex to itself). There are V vertices and E edges. 1. Assume that in addition to the conditions specified at the beginning, graphs are dense. If a graph contains V vertices and E edges, what is the greatest number...

  • 5. Here are the vertices and edges of directed graph G: V= {2.6.c.de.f} E= {ab, ac,...

    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...

  • Consider the following weighted, directed graph G. There are 7 vertices and 10 edges. The edge list E is as follows:

    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...

  • Please answer this question prefer typing if it possible. " Let G = (V,E) be a...

    Please answer this question prefer typing if it possible. " Let G = (V,E) be a directed weighted graph such that all the weights are positive. Let v and w be two vertices in G and k ≤ |V | be an integer. Design an algorithm to find the shortest path from v to w that contains exactly k edges. Note that the path need not be simple."

  • Let G = (V, E, w) be a connected weighted undirected graph. Given a vertex s...

    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)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT