By Laksman Veeravagu and Luis Barrera

Slides:



Advertisements
Similar presentations
Single Source Shortest Paths
Advertisements

CS 206 Introduction to Computer Science II 04 / 01 / 2009 Instructor: Michael Eckmann.
The Greedy Approach Chapter 8. The Greedy Approach It’s a design technique for solving optimization problems Based on finding optimal local solutions.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
CS 206 Introduction to Computer Science II 11 / 07 / 2008 Instructor: Michael Eckmann.
D IJKSTRA ' S ALGORITHM By Laksman Veeravagu and Luis Barrera Edited by: Manuela Caicedo, Francisco Morales, Rafael Feliciano, and Carlos Jimenez.
CSC 331: Algorithm Analysis Paths in Graphs. The DFS algorithm we gave is recursive. DFS generates a search tree showing paths from one vertex to all.
The Shortest Path Problem. Shortest-Path Algorithms Find the “shortest” path from point A to point B “Shortest” in time, distance, cost, … Numerous.
CSCI 3160 Design and Analysis of Algorithms Tutorial 2 Chengyu Lin.
Shortest Paths and Dijkstra's Algorithm CS 110: Data Structures and Algorithms First Semester,
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graph Algorithms: Shortest Path We are given a weighted, directed graph G = (V, E), with weight function w: E R mapping.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
D IJKSTRA ' S ALGORITHM By Laksman Veeravagu and Luis Barrera.
1 Shortest Path Calculations in Graphs Prof. S. M. Lee Department of Computer Science.
Dijkstra's algorithm.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms Shortest-Path.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Dijkstra's algorithm CS3240. The author: Edsger Wybe Dijkstra "Computer Science is no more about computers than astronomy is about telescopes."
Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar.
Dijkstra’s Algorithm Supervisor: Dr.Franek Ritu Kamboj
Shortest Path in Weighted Graph : Dijkstra’s Algorithm.
D IJKSTRA ' S ALGORITHM. S INGLE -S OURCE S HORTEST P ATH P ROBLEM Single-Source Shortest Path Problem - The problem of finding shortest paths from a.
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
1 Introduction to Algorithms L ECTURE 17 (Chap. 24) Shortest paths I 24.2 Single-source shortest paths 24.3 Dijkstra’s algorithm Edsger Wybe Dijkstra
Introduction to Algorithms All-Pairs Shortest Paths My T. UF.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Graphs – Part III CS 367 – Introduction to Data Structures.
Shortest Path Dr. Yasir. Weighted Graphs In many applications, each edge of a graph has an associated numerical value, called a weight. Usually, the edge.
Shortest Paths and Minimum Spanning Trees
CS 3343: Analysis of Algorithms
Minimum Spanning Tree Shortest Paths
CS200: Algorithm Analysis
Comp 245 Data Structures Graphs.
Greedy Algorithms / Dijkstra’s Algorithm Yin Tat Lee
Analysis and design of algorithm
4.4 Shortest Paths in a Graph
CSE 373: Data Structures and Algorithms
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Minimum Spanning Tree Algorithms
Lecture 13 Algorithm Analysis
Slide Courtesy: Uwash, UT
Lecture 13 Algorithm Analysis
CSE 373: Data Structures and Algorithms
CSE332: Data Abstractions Lecture 17: Shortest Paths
Shortest Paths.
CE 221 Data Structures and Algorithms
CSE 373 Data Structures and Algorithms
Brad Karp UCL Computer Science
Slide Courtesy: Uwash, UT
CSC 380: Design and Analysis of Algorithms
Graph Algorithms: Shortest Path
Winter 2019 Lecture 9 Dijkstra’s algorithm
Shortest path problem and its application to optical network
Dijkstra's Shortest Path Algorithm
CE 221 Data Structures and Algorithms
CSE 373: Data Structures and Algorithms
CS 3013: DS & Algorithms Shortest Paths.
Graphs: Shortest path and mst
Chapter 9 Graph algorithms
Data Structures and Algorithm Analysis Lecture 8
Autumn 2019 Lecture 9 Dijkstra’s algorithm
Presentation transcript:

By Laksman Veeravagu and Luis Barrera Dijkstra's algorithm By Laksman Veeravagu and Luis Barrera

The author: Edsger Wybe Dijkstra "Computer Science is no more about computers than astronomy is about telescopes." http://www.cs.utexas.edu/~EWD/

Edsger Wybe Dijkstra - May 11, 1930 – August 6, 2002 - Received the 1972 A. M. Turing Award, widely considered the most prestigious award in computer science. - The Schlumberger Centennial Chair of Computer Sciences at The University of Texas at Austin from 1984 until 2000 - Made a strong case against use of the GOTO statement in programming languages and helped lead to its deprecation. - Known for his many essays on programming.

Single-Source Shortest Path Problem Single-Source Shortest Path Problem - The problem of finding shortest paths from a source vertex v to all other vertices in the graph.

Dijkstra's algorithm Dijkstra's algorithm - is a solution to the single-source shortest path problem in graph theory. Works on both directed and undirected graphs. However, all edges must have nonnegative weights. Approach: Greedy Input: Weighted graph G={E,V} and source vertex v∈V, such that all edge weights are nonnegative Output: Lengths of shortest paths (or the shortest paths themselves) from a given source vertex v∈V to all other vertices

Dijkstra's algorithm - Pseudocode dist[s] ←0 (distance to source vertex is zero) for  all v ∈ V–{s}         do  dist[v] ←∞ (set all other distances to infinity) S←∅ (S, the set of visited vertices is initially empty) Q←V  (Q, the queue initially contains all vertices)               while Q ≠∅ (while the queue is not empty) do   u ← mindistance(Q,dist) (select the element of Q with the min. distance)       S←S∪{u} (add u to list of visited vertices)        for all v ∈ neighbors[u]               do  if   dist[v] > dist[u] + w(u, v) (if new shortest path found)                          then      d[v] ←d[u] + w(u, v) (set new value of shortest path) (if desired, add traceback code) return dist

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Dijkstra Animated Example

Implementations and Running Times The simplest implementation is to store vertices in an array or linked list. This will produce a running time of O(|V|^2 + |E|) For sparse graphs, or graphs with very few edges and many nodes, it can be implemented more efficiently storing the graph in an adjacency list using a binary heap or priority queue. This will produce a running time of O((|E|+|V|) log |V|)

Dijkstra's Algorithm - Why It Works As with all greedy algorithms, we need to make sure that it is a correct algorithm (e.g., it always returns the right solution if it is given correct input). A formal proof would take longer than this presentation, but we can understand how the argument works intuitively. If you can’t sleep unless you see a proof, see the second reference or ask us where you can find it.

Dijkstra's Algorithm - Why It Works To understand how it works, we’ll go over the previous example again. However, we need two mathematical results first: Lemma 1: Triangle inequality If δ(u,v) is the shortest path length between u and v, δ(u,v) ≤ δ(u,x) + δ(x,v) Lemma 2: The subpath of any shortest path is itself a shortest path. The key is to understand why we can claim that anytime we put a new vertex in S, we can say that we already know the shortest path to it. Now, back to the example…

Dijkstra's Algorithm - Why use it? As mentioned, Dijkstra’s algorithm calculates the shortest path to every vertex. However, it is about as computationally expensive to calculate the shortest path from vertex u to every vertex using Dijkstra’s as it is to calculate the shortest path to some particular vertex v. Therefore, anytime we want to know the optimal path to some other vertex from a determined origin, we can use Dijkstra’s algorithm.

Applications of Dijkstra's Algorithm - Traffic Information Systems are most prominent use - Mapping (Map Quest, Google Maps) - Routing Systems

Applications of Dijkstra's Algorithm One particularly relevant this week: epidemiology Prof. Lauren Meyers (Biology Dept.) uses networks to model the spread of infectious diseases and design prevention and response strategies. Vertices represent individuals, and edges their possible contacts. It is useful to calculate how a particular individual is connected to others. Knowing the shortest path lengths to other individuals can be a relevant indicator of the potential of a particular individual to infect others.

References Dijkstra’s original paper: E. W. Dijkstra. (1959) A Note on Two Problems in Connection with Graphs. Numerische Mathematik, 1. 269-271. MIT OpenCourseware, 6.046J Introduction to Algorithms. < http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and- Computer-Science/6-046JFall-2005/CourseHome/> Accessed 4/25/09 Meyers, L.A. (2007) Contact network epidemiology: Bond percolation applied to infectious disease prediction and control. Bulletin of the American Mathematical Society 44: 63-86. Department of Mathematics, University of Melbourne. Dijkstra’s Algorithm. <http://www.ms.unimelb.edu.au/~moshe/620- 261/dijkstra/dijkstra.html > Accessed 4/25/09