dijkstra’s shortest path algorithm neil tang 03/25/2008

14
CS223 Advanced Data Structures and Algorithms 1 Dijkstra’s Shortest Path Algorithm Dijkstra’s Shortest Path Algorithm Neil Tang Neil Tang 03/25/2008 03/25/2008

Upload: decker

Post on 04-Jan-2016

59 views

Category:

Documents


0 download

DESCRIPTION

Dijkstra’s Shortest Path Algorithm Neil Tang 03/25/2008. Class Overview. The shortest path problem Applications Dijkstra’s algorithm Implementation and time complexities. Shortest Path Problem. Weighted path length (cost): The sum of the weights of all links on the path. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 1

Dijkstra’s Shortest Path Algorithm Dijkstra’s Shortest Path Algorithm

Neil TangNeil Tang03/25/200803/25/2008

Page 2: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 2

Class OverviewClass Overview

The shortest path problem

Applications

Dijkstra’s algorithm

Implementation and time complexities

Page 3: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 3

Shortest Path ProblemShortest Path Problem

Weighted path length (cost): The sum of the weights of all links on the path.

The single-source shortest path problem: Given a weighted graph G and a source vertex s, find the shortest (minimum cost) path from s to every other vertex in G.

Page 4: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 4

An ExampleAn Example

Page 5: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 5

Another ExampleAnother Example

Page 6: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 6

ApplicationsApplications

Digital map

Computer network

Travel planning

Page 7: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 7

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 8: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 8

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 9: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 9

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 10: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 10

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 11: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 11

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 12: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 12

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 13: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 13

Dijkstra’s AlgorithmDijkstra’s Algorithm

Page 14: Dijkstra’s Shortest Path Algorithm  Neil Tang 03/25/2008

CS223 Advanced Data Structures and Algorithms 14

Implementation and Time ComplexitiesImplementation and Time Complexities

Trivial: O(|V|2 + |E|) = O(|V|2)

Heap: deleteMin |V| times + decreaseKey |E| times

O(|V|log|V| + |E|log|V|) = O (|E|log|V|)

Fibonacci heap: O(|E| + |V|log|V|)