Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shortest Route Problems

Similar presentations


Presentation on theme: "Shortest Route Problems"— Presentation transcript:

1 Shortest Route Problems

2 Traveling Salesperson Problem
The traveling salesperson problem asks that a Hamiltonian circuit of least total weight be found for a graph. But what if you don’t need to visit every vertex but instead needed only to find the shortest route from one vertex to another? An efficient method for solving this type of problem does exist, an algorithm attributed to E. W. Dijkstra.

3 Edsger W. Dijkstra E. W. Dijkstra was born in the Netherlands in 1930.
He is considered to be one of the original theorists of modern computer science. He first published his algorithm about the shortest path algorithm in a German journal in 1959.

4 Shortest Path Algorithm
This is a modification of Dijkstra’s algorithm: Label the starting vertex S and circle it. Examine all edged that have S as an endpoint. Darken the edge with the shortest length and circle the vertex at the other endpoint of the darkened edge. Examine all uncircled vertices that are adjacent to the circled vertices in the graph.

5 Algorithm (cont’d) Using only circled vertices and darkened edges between the vertices that are circled, find the lengths of all paths from S to each vertex being examined. Choose the vertex and edge that yield the shortest path. Circle this vertex and darken this edge. Ties are broken arbitrarily. Repeat Steps 2 and 3 until all vertices are circled. The darkened edges of the graph form the shortest routes from S to every other vertex in the graph.

6 Example Use the shortest path algorithm to find the shortest path form A to F in the graph. C 6 E 2 3 4 5 A 2 F 5 4 3 B D

7 Using the Algorithm To find the solution to this problem, begin by circling vertex A and labeling it S. Examine all vertices that are adjacent to S. Adjacent Vertices Path from S to Vertex Length of Path Adjacent to S B SB 5 C SC 2 1. Circle C, darken the edge SC. Adjacent to C SCB 4 E SCE 8 D SCD 6 continued

8 Example Adjacent Vertices Path from S to Vertex Length of Path
2. Circle B, darken edge CB. Adjacent to C E SCE 8 D SCD 6 Adjacent to B SCBD 7 3. Circle D, darken edge CD. Adjacent to D SCDE 11 F SCDF 10 4. Circle E, darken edge CE Adjacent to E SCEF 5. Circle F, darken edge DF

9 Shortest Route The shortest route from A to F is A, C, D, F and the length is 10. The darkened edges show the shortest routes from A to the other vertices in the graph.

10 Graph Step 4 C 6 E 2 3 4 5 A 2 F S 5 4 3 B D Step 1 Step 5 Step 2

11 Practice Problems Use the shortest path algorithm to find the shortest route from A to F. A D 2 3 8 2 F 5 6 1 C 8 3 B E

12 Practice Problems (cont’d)
Use the shortest path algorithm to determine the shortest distance from S to each of the other vertices. M 3 2 N 2 1 S J 1 5 2 4 L 3 K


Download ppt "Shortest Route Problems"

Similar presentations


Ads by Google