Question: help me please Use Dijkstra's algorithm to solve the single source shortest path problem on the directed graph G(V,E):V={s,1,2,3,4,5}. Edge weights are: W(s,1)=2,W(s,2)=15,W(1,3)=6,W(1,4)=3,W(2,4)=4,W(2,5)=2,W(3,4)=2,W(4,2)=5,W(4,3)= 1,W(4,5)=5 Hint:

Use Dijkstra's algorithm to solve the single source shortest path problem on the directed graph G(V,E):V={s,1,2,3,4,5}. Edge weights are: W(s,1)=2,W(s,2)=15,W(1,3)=6,W(1,4)=3,W(2,4)=4,W(2,5)=2,W(3,4)=2,W(4,2)=5,W(4,3)= 1,W(4,5)=5 Hint: follow the example in slide 23: Sloution: - At the beginning of the algorithm, we calculate dist( distance): - dist(s)=0;dist(1)=;dist(2)=dist(3)=dist(4)=dist(5)= - In stage 1, node has the minimum dist value and hence is inserted into the set S. Nodes and are neighbors of and hence we have to check if the dist values of these nodes have to be modified. Since dist > dist ( , we change dist ( Likewise we set dist , L . - In stage 2, node has the minimum dist value and hence is inserted into S. Nodes 2,3 , and 5 are neighbors of . The new dist values of these nodes become: dist(2)= dist(3)=dist(5)= +, we change dist ( ito Likewise we set dist ()= - In stage 2, node has the minimum dist value and hence is inserted into S. Nodes 2,3 , and 5 are neighbors of . The new dist values of these nodes become: dist(2)= dist(3)=dist(5)= - In stage 3, node has the minimum dist value and it becomes a part of S. All the neighbors of are already in S and the dist values of the nodes 2 and 5 do not change. - In stage 4, we have two nodes both having the same dist value. We could pick one arbitrarily and insert it into S. Let 2 be this node. The dist value of 5 does not change. - In stage 5, the node 5 also enters S. Algorithm terminates then. - Thus, the shortest paths from s to the nodes 1,2,3,4, and 5 are , and respectively
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
