1 Single-source shortest path Shortest Path Given a weighted directed graph, one common problem is finding the shortest path between two given vertices.

Slides:



Advertisements
Similar presentations
Bellman-Ford algorithm
Advertisements

Problem solving with graph search
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Design and Analysis of Algorithms Single-source shortest paths, all-pairs shortest paths Haidong Xue Summer 2012, at GSU.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
Chapter 9 Graph algorithms. Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Chapter 9 Graph algorithms Lec 21 Dec 1, Sample Graph Problems Path problems. Connectedness problems. Spanning tree problems.
Shortest path algorithm. Introduction 4 The graphs we have seen so far have edges that are unweighted. 4 Many graph situations involve weighted edges.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Algorithm design techniques
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Shortest Paths Introduction to Algorithms Shortest Paths CSE 680 Prof. Roger Crawfis.
Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
David Luebke 1 9/13/2015 CS 332: Algorithms S-S Shortest Path: Dijkstra’s Algorithm Disjoint-Set Union Amortized Analysis.
1 Shortest Path Problem Topic 11 ITS033 – Programming & Algorithms C B A E D F Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program,
COSC 2007 Data Structures II Chapter 14 Graphs III.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Network and Communications Ju Wang Chapter 5 Routing Algorithm Adopted from Choi’s notes Virginia Commonwealth University.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
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.
Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca.
Shortest Path Algorithms. Definitions Variants  Single-source shortest-paths problem: Given a graph, finding a shortest path from a given source.
Fundamental Data Structures and Algorithms (Spring ’05) Recitation Notes: Graphs Slides prepared by Uri Dekel, Based on recitation.
Pipelining and Retiming
1 Prim’s algorithm. 2 Minimum Spanning Tree Given a weighted undirected graph G, find a tree T that spans all the vertices of G and minimizes the sum.
Introduction to Algorithms All-Pairs Shortest Paths My T. UF.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
1 Graph theory Outline A graph is an abstract data type for storing adjacency relations –We start with definitions: Vertices, edges, degree and sub-graphs.
1 A* search Outline In this topic, we will look at the A* search algorithm: –It solves the single-source shortest path problem –Restricted to physical.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
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.
David Luebke 1 11/21/2016 CS 332: Algorithms Minimum Spanning Tree Shortest Paths.
Unit 11 Graphs (2) King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department.
Network Layer COMPUTER NETWORKS Networking Standards (Network LAYER)
Topological Sort In this topic, we will discuss: Motivations
Minimum Spanning Trees
What is a router? A router is a device that connects multiple computers together. Not to be confused with a switch Routers transmit packets of data across.
I206: Lecture 15: Graphs Marti Hearst Spring 2012.
unweighted path lengths
Graph Algorithm.
Poisson distribution.
Shortest Paths C B A E D F Shortest Paths
Open addressing.
All-pairs Shortest Path
All-pairs shortest path
Outline This topic covers Prim’s algorithm:
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Floyd’s Algorithm (shortest-path problem)
Lecture 13 Algorithm Analysis
Lecture 13 Algorithm Analysis
Networks Kruskal’s Algorithm
CSE 373: Data Structures and Algorithms
Weighted Graphs & Shortest Paths
Dijkstra’s Shortest Path Algorithm Neil Tang 3/2/2010
CSE 417: Algorithms and Computational Complexity
CS 3013: DS & Algorithms Shortest Paths.
Graphs: Shortest path and mst
Chapter 9 Graph algorithms
Counting sort.
Topological Sorting Minimum Spanning Trees Shortest Path
Prims’ spanning tree algorithm
Presentation transcript:

1 Single-source shortest path Shortest Path Given a weighted directed graph, one common problem is finding the shortest path between two given vertices –Recall that in a weighted graph, the length of a path is the sum of the weights of each of the edges in that path

2 Single-source shortest path Shortest Path Given the graph we used in the previous topic, suppose we wish to find the shortest path from vertex 1 to vertex 13

3 Single-source shortest path Shortest Path After some consideration, we may determine that the shortest path is as follows, with length 14 Other paths exists, but they are longer

4 Single-source shortest path Applications In circuit design, one application is circuit design: the time it takes for a change in input to affect an output depends on the shortest path

5 Single-source shortest path Applications The Internet is a collection of interconnected computer networks –Information is passed through packets Packets are passed from the source, through routers, to their destination Routers are connected to either: –individual computers, or –other routers These may be represented as graphs

6 Single-source shortest path Applications A visualization of the graph of the routers and their various connections through a portion of the Internet

7 Single-source shortest path Applications The path a packet takes depends on the IP address Metrics for measuring the shortest path may include: –low latency (minimize time), or –minimum hop count (all edges have weight 1)

8 Single-source shortest path Applications In software engineering, one obvious problem is finding the shortest route between two points on a map –Shortest path, however, need not refer to distance...

9 Single-source shortest path Applications The shortest path using distance as a metric is obvious, however, a driver may be more interested in minimizing time For example, using the 407 may be preferable to using the 401 during rush hour, however, there is an added cost

10 Single-source shortest path Applications A company will be interested in minimizing the cost which includes the following factors: –salary of the truck driver (overtime?) –possible tolls and administrative costs –bonuses for being early –penalties for being late –cost of fuel

11 Single-source shortest path Applications Very quickly, the definition of the shortest path becomes time- dependant: –rush hour –long weekends and situation dependant: –scheduled events (e.g., road construction) –unscheduled events (e.g., accidents)

12 Single-source shortest path Shortest Path The goal of this algorithm will be to find the shortest path and its length We will make the assumption that the weights on all edges is a positive number –Clearly, if we have negative edges, it may be possible to end up in a cycle whereby each pass through the cycle decreases the total length –Thus, a shortest length would be undefined for such a graph –Consider the shortest path from vertex 1 to 4...

13 Single-source shortest path Shortest Path Consider the following graph –All edges have positive weight –There exists cycles—it is not a DAG

14 Single-source shortest path Algorithms Algorithms for finding the shortest path include: –Dijkstra’s algorithm –A* search algorithm –Bellman-Ford algorithm

15 Single-source shortest path Dijkstra’s algorithm Dijkstra’s algorithm works on graphs where the weights on all edges is positive –The set-up is very similar to Prim’s algorithm –It requires one small change…

16 Single-source shortest path Triangle Inequality If the distances satisfy the triangle inequality, –That is, the distance between a and b is less than the distance from a to c plus the distance from c to b, we can use the A* search which is faster than Dijkstra’s algorithm –All Euclidean distances satisfy the triangle inequality

17 Single-source shortest path Negative Weights If some of the edges have negative weight, so long as there are no cycles with negative weight, the Bellman-Ford algorithm will find the minimum distance –It is slower than Dijkstra’s algorithm

18 Single-source shortest path Summary Given a weighted directed graph, we can find the shortest distance between two vertices by: –starting with a trivial path containing the initial vertex –growing this path by always going to the next vertex which has the shortest current path

19 Single-source shortest path References Wikipedia, These slides are provided for the ECE 250 Algorithms and Data Structures course. The material in it reflects Douglas W. Harder’s best judgment in light of the information available to him at the time of preparation. Any reliance on these course slides by any party for any other purpose are the responsibility of such parties. Douglas W. Harder accepts no responsibility for damages, if any, suffered by any party as a result of decisions made or actions based on these course slides for any other purpose than that for which it was intended.