Shortest paths
This presentation is the property of its rightful owner.
Sponsored Links
1 / 27

Shortest Paths PowerPoint PPT Presentation


  • 50 Views
  • Uploaded on
  • Presentation posted in: General

Shortest Paths. Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 9.6 Based on slides from Chuck Allison, Michael T. Goodrich, and Roberto Tamassia By Longin Jan Latecki. BOS. NY. CHI. SF. DEN. ATL. LA. MIA. Weighted Graphs.

Download Presentation

Shortest Paths

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Shortest paths

Shortest Paths

Text

Discrete Mathematics and Its Applications(5th Edition)

Kenneth H. Rosen

Chapter 9.6

Based on slides from Chuck Allison, Michael T. Goodrich, and Roberto Tamassia

By Longin Jan Latecki


Weighted graphs

BOS

NY

CHI

SF

DEN

ATL

LA

MIA

Weighted Graphs

Graphs that have a number assigned to each edge are called weighted graphs.


Weighted graphs1

BOS

NY

CHI

SF

DEN

ATL

LA

MIA

Weighted Graphs

MILES

860

2534

191

1855

722

908

957

760

606

834

349

2451

1090

595


Weighted graphs2

BOS

NY

CHI

SF

DEN

ATL

LA

MIA

Weighted Graphs

FARES

$129

$79

$39

$99

$59

$69

$89

$79

$99

$89

$39

$129

$69


Weighted graphs3

BOS

NY

CHI

SF

DEN

ATL

LA

MIA

Weighted Graphs

FLIGHT TIMES

4:05

2:10

0:50

2:55

1:50

2:10

2:20

1:55

1:40

2:45

2:00

3:50

1:15

1:30


Weighted graphs4

Weighted Graphs

  • A weighted graph is a graph in which each edge (u, v) has a weight w(u, v). Each weight is a real number.

  • Weights can represent distance, cost, time, capacity, etc.

  • The length of a path in a weighted graph is the sum of the weights on the edges.

  • Dijkstra’s Algorithm finds the shortest path between two vertices.


Dijkstra s algorithm

Dijkstra's Algorithm


Dijkstra animation

Dijkstra Animation

  • Demo


Problem shortest path from a to z

Problem: shortest path from a to z

f

b

d

5

5

4

7

3

4

1

2

a

z

3

4

c

5

e

5

g


Shortest paths

1

20

15

5

35

75

10

2

3

7

50

40

35

15

4

6

10


Theorems

Theorems

Dijkstra’s algorithm finds the length of a shortest path between two vertices in a connected simple undirected weighted graph G=(V,E).

The time required by Dijkstra's algorithm is O(|V|2).

It will be reduced to O(|E|log|V|) if heap is used to keep {vV\Si : L(v) < }, where Si is the set S after iteration i.


The traveling salesman problem

The Traveling Salesman Problem

  • The traveling salesman problem is one of the classical problems in computer science.

  • A traveling salesman wants to visit a number of cities and then return to his starting point. Of course he wants to save time and energy, so he wants to determine the shortest cycle for his trip.

  • We can represent the cities and the distances between them by a weighted, complete, undirected graph.

  • The problem then is to find the shortest cycle (of minimum total weight that visits each vertex exactly one).

  • Finding the shortest cycle is different than Dijkstra’s shortest path.It is much harder too, no polynomial time algorithm exists!


The traveling salesman problem1

The Traveling Salesman Problem

  • Importance:

    • Variety of scheduling application can be solved as atraveling salesmen problem.

    • Examples:

      • Ordering drill position on a drill press.

      • School bus routing.

    • The problem has theoretical importance because it represents a class of difficult problems known as NP-hard problems.


The federal emergency management agency

THE FEDERAL EMERGENCY MANAGEMENT AGENCY

  • A visit must be made to four local offices of FEMA, going out from and returning to the same main office in Northridge, Southern California.


Fema traveling salesman network representation

FEMA traveling salesmanNetwork representation


Shortest paths

40

2

3

25

35

50

40

50

1

4

65

45

30

80

Home


Fema traveling salesman

FEMA - Traveling Salesman

  • Solution approaches

    • Enumeration of all possible cycles.

      • This results in (m-1)! cycles to enumerate for a graph with m nodes.

      • Only small problems can be solved with this approach.


Fema full enumeration

FEMA – full enumeration

Possible cycles

CycleTotal Cost

1. H-O1-O2-O3-O4-H210

2. H-O1-O2-O4-O3-H 195

3. H-O1-O3-O2-O3-H 240

4. H-O1-O3-O4-O2-H 200

5. H-O1-O4-O2-O3-H 225

6. H-O1-O4-O3-O2-H 200

7. H-O2-O3-O1-O4-H 265

8. H-O2-O1-O3-O4-H 235

9. H-O2-O4-O1-O3-H 250

10. H-O2-O1-O4-O3-H 220

11. H-O3-O1-O2-O4-H 260

12. H-O3-O1-O2-O4-H260

Minimum

For this problem we have (5-1)! / 2 = 12 cycles. Symmetrical problemsneed to enumerate only (m-1)! / 2 cycles.


Fema optimal solution

FEMA – optimal solution

40

2

3

25

35

50

40

1

50

4

65

45

30

80

Home


The traveling salesman problem2

The Traveling Salesman Problem

  • Unfortunately, no algorithm solving the traveling salesman problem with polynomial worst-case time complexity has been devised yet.

  • This means that for large numbers of vertices, solving the traveling salesman problem is impractical.

  • In these cases, we can use efficient approximation algorithms that determine a path whose length may be slightly larger than the traveling salesman’s path, but


  • Login