Shortest Paths and Dijkstra's Algorithm CS 110: Data Structures and Algorithms First Semester, 2010-2011.

Slides:



Advertisements
Similar presentations
Chapter 9: Graphs Shortest Paths
Advertisements

Spring 2007Shortest Paths1 Minimum Spanning Trees JFK BOS MIA ORD LAX DFW SFO BWI PVD
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.
CSCI 3160 Design and Analysis of Algorithms Tutorial 2 Chengyu Lin.
Shortest Paths1 C B A E D F
CSC 213 Lecture 23: Shortest Path Algorithms. Weighted Graphs Each edge in weighted graph has numerical weight Weights can be distances, building costs,
CS 206 Introduction to Computer Science II 11 / 10 / 2008 Instructor: Michael Eckmann.
Lecture 22: Matrix Operations and All-pair Shortest Paths II Shang-Hua Teng.
Graph Algorithms: Shortest Path We are given a weighted, directed graph G = (V, E), with weight function w: E R mapping.
© 2004 Goodrich, Tamassia Shortest Paths1 Shortest Paths (§ 13.6) Given a weighted graph and two vertices u and v, we want to find a path of minimum total.
1 Graphs: shortest paths Fundamental Data Structures and Algorithms Ananda Guna April 3, 2003.
© 2004 Goodrich, Tamassia Minimum Spanning Trees1 Minimum Spanning Trees (§ 13.7) Spanning subgraph Subgraph of a graph G containing all the vertices of.
CSC311: Data Structures 1 Chapter 13: Graphs II Objectives: Graph ADT: Operations Graph Implementation: Data structures Graph Traversals: DFS and BFS Directed.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Shortest Paths1 C B A E D F
© 2004 Goodrich, Tamassia Shortest Paths1 C B A E D F
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Lecture20: Graph IV Bohyung Han CSE, POSTECH CSED233: Data Structures (2014F)
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Weighted Graphs In a weighted graph, each edge has an associated numerical value, called the weight of the edge Edge weights may represent, distances,
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
© 2010 Goodrich, Tamassia Shortest Paths1 C B A E D F
1 Shortest Path Problem Topic 11 ITS033 – Programming & Algorithms C B A E D F Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program,
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
Graphs Part 2. Shortest Paths C B A E D F
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is meant by weighted graphs  Where weights placed within Graph  How to use Graph ’s.
Minimum-Cost Spanning Tree CS 110: Data Structures and Algorithms First Semester,
Lecture 16. Shortest Path Algorithms
Shortest Paths and Dijkstra’s Algorithm CS 105. SSSP Slide 2 Single-source shortest paths Given a weighted graph G and a source vertex v in G, determine.
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.
Shortest Path Graph Theory Basics Anil Kishore.
1 Dijkstra’s Algorithm Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is meant by weighted graphs  Where weights placed within Graph  How to use Graph ’s.
Data Structures & Algorithms Shortest Paths Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
CSC 213 – Large Scale Programming. Minimum Spanning Tree (MST)  Spanning subgraph  Subgraph w/ all vertices ORD PIT ATL STL DEN DFW DCA
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
© 2010 Goodrich, Tamassia Shortest Paths1 C B A E D F
1 COMP9024: Data Structures and Algorithms Week Twelve: Graphs (II) Hui Wu Session 1, 2014
Minimum-cost spanning tree
Shortest Paths C B A E D F Shortest Paths
Minimum-Cost Spanning Tree and Kruskal’s Algorithm
COMP9024: Data Structures and Algorithms
Shortest Paths C B A E D F Shortest Paths
Shortest Path 6/18/2018 4:22 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Shortest Paths C B A E D F Shortest Paths 1
Shortest Paths C B A E D F Shortest Paths
Shortest Paths C B A E D F Shortest Paths
Shortest Paths C B A E D F
Network Routing.
Shortest Paths C B A E D F Shortest Paths
Shortest Paths C B A E D F Shortest Paths
CSE 373: Data Structures and Algorithms
Chapter 13 Graph Algorithms
Dijkstra’s Shortest Path Algorithm Neil Tang 03/25/2008
Case study: Strava + Waze
Minimum Spanning Trees
Single-source shortest paths
CSE 373: Data Structures and Algorithms
Algorithms: Design and Analysis
Shortest Path Algorithm for Weighted Non-negative Undirected Graphs
Dijkstra’s Shortest Path Algorithm Neil Tang 3/2/2010
Shortest Paths.
CE 221 Data Structures and Algorithms
Graph Algorithms: Shortest Path
CSE 417: Algorithms and Computational Complexity
Dijkstra's Shortest Path Algorithm
CE 221 Data Structures and Algorithms
Graphs: Shortest path and mst
Presentation transcript:

Shortest Paths and Dijkstra's Algorithm CS 110: Data Structures and Algorithms First Semester,

Single-Source Shortest Paths ► Given a weighted graph G and a source vertex v in G, determine the shortest paths from v to all other vertices in G ► Path length: sum of all edges in path ► Useful in road map applications (e.g., Google maps or map quest) for example

Dijkstra’s Algorithm ► Solves the single-source shortest path problem ► Involves keeping a table of current shortest path lengths from a source vertex (initialize to infinity for all vertices except v, which has length 0)

Dijkstra’s Algorithm ► Repeatedly select the vertex u with shortest path length, and update other lengths by considering the path that passes through that vertex ► Stop when all vertices have been selected

Dijkstra’s Algorithm ► Can make use of a priority queue to facilitate selection of shortest lengths ► Need to refine the data structure to allow the updating of key values ► Time complexity: O(n+m) or O(n 2 log n) ► O(n 2 ) if computation of minimum is simplified

MIA JFK PVD BOS DFW SFO LAX BWI ORD Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ 0 Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ 621 ∞ ∞ 946 ∞ 184 ∞ 0 Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ 621 ∞ ∞ 946 ∞ 184 ∞ 0 Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD ∞ Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD Dijkstra’s Algorithm

MIA JFK PVD BOS DFW SFO LAX BWI ORD Dijkstra’s Algorithm

Pseudo-Code: Dijkstra function Dijkstra( Graph g, Vertex source ) for each vertex v in g dist[v] <-- infinity previous[v] <-- undefined dist[source] <-- 0 Q <-- the set of all nodes in Graph while Q is not empty u <-- vertex in Q with smallest dist[] if dist[u] == infinity break remove u from Q for each neighbor v of u alt = dist[u] + dist_between( u, v ) if alt < dist[v] dist[v] = alt previous[v] = u return dist[]