70 likes | 206 Views
Dijkstra’s (Shortest Path Algorithm). How to do it. 1.Label the starting vertex S & circle it. Examine all edges that have S as an end point. Darken the edge w/ the shortest length & circle the vertex at the other endpoint.
E N D
How to do it 1.Label the starting vertex S & circle it. Examine all edges that have S as an end point. Darken the edge w/ the shortest length & circle the vertex at the other endpoint. 2. Examine all uncircled vertices that are adjacent to the circled vertices in the graph. 3. Find the length of every path between S an uncircled. Select the shortest path. 4. Repeat until all vertices are circled.
EXAMPLEFind shortest path from A to F in the graph. C 6 E 2 3 A 52 4 54 F B 3 D FDFF;.JK\
Step4 Step3 Step 1 C 6 E 2 3 A 52 4 54 F B 3 D Step 2 Step 5 The shortest route from A to F is A, C, D, F, & the length is 10. FDFF;.JK\
Adjacent vertices Path from x to vertex length of path Adjacent to S B SB 5 C SC 2 1.CIRCLE C, DARKEN EDGE SC. Adjacent to S B SB 5 Adjacent to C B SCB 4 E SCE 8 D SCD 6 2.CIRCLE B, DARKEN EDGE CB. Adjacent to C E SCE 8 D SCD 6 Adjacent to B D SCBD 7 3.CIRCLE D, DARKENEDGE CD. Adjacent to C E SCE 8 Adjacent to D E SCDE 11 F SCDF 10
Adjacent vertices Path from x to vertex length of path 4.CIRCLE E, DARKEN EDGE CE.Adjacent to E F SCEF 11Adjacent to D F SCDF 105.CIRCLE F, DARKEN EDGE DF.