Dijkstra’s algorithm proceeds as follows:
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)
3. Let G=(V.E) be a weighted, directed graph with weight function w: E->{0,1,...,W} for some nonnegative...
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.
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...
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...
Let G=(V, E) be a connected graph with a weight w(e) associated with each edge e. Suppose G has n vertices and m edges. Let E’ be a given subset of the edges of E such that the edges of E’ do not form a cycle. (E’ is given as part of input.) Design an O(mlogn) time algorithm for finding a minimum spanning tree of G induced by E’. Prove that your algorithm indeed runs in O(mlogn) time. A minimum...
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...