Lecture 18 Solving Shortest Path Problem: Dijkstra s Algorithm. October 23, 2009

Similar documents
Description of The Algorithm

Artificial Intelligence

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

CS350: Data Structures Dijkstra s Shortest Path Alg.

1 Dynamic Programming

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15

Routing. Information Networks p.1/35

Shortest path problems

MA 252: Data Structures and Algorithms Lecture 36. Partha Sarathi Mandal. Dept. of Mathematics, IIT Guwahati

2.3 Optimal paths. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

1 More on the Bellman-Ford Algorithm

Lecture 11: Analysis of Algorithms (CS ) 1

2.3 Optimal paths. Optimal (shortest or longest) paths have a wide range of applications:

CHAPTER 13 GRAPH ALGORITHMS

Lecture 19 Shortest Path vs Spanning Tree Max-Flow Problem. October 25, 2009

Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis

CS 231: Algorithmic Problem Solving

Single Source Shortest Path (SSSP) Problem

Lecture 6 Basic Graph Algorithms

Single Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

4. Linear Programming

Algorithm Circle Extra Lecture: Solving the Assignment Problem with Network Flow

Algorithms for Data Science

Algorithms for Data Science

Dijkstra s Algorithm. Dijkstra s algorithm is a natural, greedy approach towards

Algorithms. All-Pairs Shortest Paths. Dong Kyue Kim Hanyang University

CS490 Quiz 1. This is the written part of Quiz 1. The quiz is closed book; in particular, no notes, calculators and cell phones are allowed.

Chapter 25: All-Pairs Shortest-Paths

Lecture I: Shortest Path Algorithms

Graphs II - Shortest paths

Lecture 3: Totally Unimodularity and Network Flows

Lecture 6: Shortest distance, Eulerian cycles, Maxflow

Shortest Paths D E. Shortest Paths 1

Shortest Paths. Nishant Mehta Lectures 10 and 11

Dynamic Programming: 1D Optimization. Dynamic Programming: 2D Optimization. Fibonacci Sequence. Crazy 8 s. Edit Distance

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Graph Algorithms (part 3 of CSC 282),

Analysis of Algorithms, I

Introduction Single-source shortest paths All-pairs shortest paths. Shortest paths in graphs

Solving problems on graph algorithms

Graph Algorithms shortest paths, minimum spanning trees, etc.

ECE 333: Introduction to Communication Networks Fall 2001

Review of course COMP-251B winter 2010

Applications of Linear Programming

Directed Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1

Graph Algorithms shortest paths, minimum spanning trees, etc.

All Shortest Paths. Questions from exercises and exams

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

CSC 373: Algorithm Design and Analysis Lecture 8

Algorithms and Data Structures

Dynamic-Programming algorithms for shortest path problems: Bellman-Ford (for singlesource) and Floyd-Warshall (for all-pairs).

Graph Algorithms (part 3 of CSC 282),

Shortest Paths. Nishant Mehta Lectures 10 and 11

ME/CS 132: Advanced Robotics: Navigation and Vision

The Shortest Path Problem

Title. Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis. Nesrine Damak. Fakultät für Informatik TU München. 20.

Dynamic Programming II

Dynamic Programming Shabsi Walfish NYU - Fundamental Algorithms Summer 2006

Chapter 6. Dynamic Programming

Shortest Paths. CSE 373 Data Structures Lecture 21

International Journal of Emerging Technologies in Computational and Applied Sciences (IJETCAS)

cs/ee 143 Fall

Communication Networks I December 4, 2001 Agenda Graph theory notation Trees Shortest path algorithms Distributed, asynchronous algorithms Page 1

Principles of Wireless Sensor Networks

CMPE 150: Introduction to Computer Networks

and 6.855J. The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem

PBW 654 Applied Statistics - I Urban Operations Research. Unit 3. Network Modelling

CSE 502 Class 23. Jeremy Buhler Steve Cole. April BFS solves unweighted shortest path problem. Every edge traversed adds one to path length

COM-208: Computer Networks - Homework 6

More Graph Algorithms: Topological Sort and Shortest Distance

Design and Analysis of Algorithms 演算法設計與分析. Lecture 13 December 18, 2013 洪國寶

Lecture #7. 1 Introduction. 2 Dijkstra s Correctness. COMPSCI 330: Design and Analysis of Algorithms 9/16/2014

COMP 182: Algorithmic Thinking Prim and Dijkstra: Efficiency and Correctness

Routing Algorithms. CS158a Chris Pollett Apr 4, 2007.

Discrete Optimization 2010 Lecture 5 Min-Cost Flows & Total Unimodularity

Virtual University of Pakistan

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Comparison of the moore s method and dijkstra s algorithm in determing the shortest path between two points on a map

Breadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2

Module 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm

Dijkstra's algorithm Prim's algorithm

CS420/520 Algorithm Analysis Spring 2009 Lecture 14

Solutions to Problem Set 3

CS 3410 Ch 14 Graphs and Paths

Outline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths

Unit-5 Dynamic Programming 2016

CROATIAN OPEN COMPETITION IN INFORMATICS 2011/2012. Round 7. Croatian Olympiad in Informatics SOLUTIONS

CS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019

Chapter 24. Shortest path problems. Chapter 24. Shortest path problems. 24. Various shortest path problems. Chapter 24. Shortest path problems

Last week: Breadth-First Search

CMSC351 - Fall 2014, Homework #6

Minimum Spanning Trees

7. NETWORK FLOW III. assignment problem input-queued switching. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley

Single Source Shortest Path

Discrete Mathematics, Spring 2004 Homework 8 Sample Solutions

Data and Computer Communications. Chapter 12 Routing in Switched Networks

Youki Kadobayashi NAIST

PATH FINDING AND GRAPH TRAVERSAL

Lecture 14: Shortest Paths Steven Skiena

Exercise 3. RIP and OSPF

Transcription:

Solving Shortest Path Problem: Dijkstra s Algorithm October 23, 2009

Outline Lecture 18 Focus on Dijkstra s Algorithm Importance: Where it has been used? Algorithm s general description Algorithm steps in detail Example Operations Research Methods 1

Lecture 18 One-To-All Shortest Path Problem We are given a weighted network (V, E, C) with node set V, edge set E, and the weight set C specifying weights cij for the edges (i, j) E. We are also given a starting node s V. The one-to-all shortest path problem is the problem of determining the shortest path from node s to all the other nodes in the network. The weights on the links are also referred as costs. Operations Research Methods 2

Algorithms Solving the Problem Dijkstra s algorithm Solves only the problems with nonnegative costs, i.e., c ij 0 for all (i, j) E Bellman-Ford algorithm Applicable to problems with arbitrary costs Floyd-Warshall algorithm Applicable to problems with arbitrary costs Solves a more general all-to-all shortest path problem Floyd-Warshall and Bellman-Ford algorithm solve the problems on graphs that do not have a cycle with negative cost. Operations Research Methods 3

Importance of Dijkstra s algorithm Many more problems than you might at first think can be cast as shortest path problems, making Dijkstra s algorithm a powerful and general tool. For example: Dijkstra s algorithm is applied to automatically find directions between physical locations, such as driving directions on websites like Mapquest or Google Maps. In a networking or telecommunication applications, Dijkstra s algorithm has been used for solving the min-delay path problem (which is the shortest path problem). For example in data network routing, the goal is to find the path for data packets to go through a switching network with minimal delay. It is also used for solving a variety of shortest path problems arising in plant and facility layout, robotics, transportation, and VLSI design Very Large Scale Integration Operations Research Methods 4

General Description Suppose we want to find a shortest path from a given node s to other nodes in a network (one-to-all shortest path problem) Dijkstra s algorithm solves such a problem It finds the shortest path from a given node s to all other nodes in the network Node s is called a starting node or an initial node How is the algorithm achieving this? Dijkstra s algorithm starts by assigning some initial values for the distances from node s and to every other node in the network It operates in steps, where at each step the algorithm improves the distance values. At each step, the shortest distance from node s to another node is determined Operations Research Methods 5

Formal Description The algorithm characterizes each node by its state The state of a node consists of two features: distance value and status label Distance value of a node is a scalar representing an estimate of the its distance from node s. Status label is an attribute specifying whether the distance value of a node is equal to the shortest distance to node s or not. The status label of a node is Permanent if its distance value is equal to the shortest distance from node s Otherwise, the status label of a node is Temporary The algorithm maintains and step-by-step updates the states of the nodes At each step one node is designated as current Operations Research Methods 6

Notation In what follows: d l denotes the distance value of a node l. p or t denotes the status label of a node, where p stand for permanent and t stands for temporary c ij is the cost of traversing link (i, j) as given by the problem The state of a node l is the ordered pair of its distance value d l and its status label. Operations Research Methods 7

Algorithm Steps Step 1. Initialization Assign the zero distance value to node s, and label it as Permanent. [The state of node s is (0, p).] Assign to every node a distance value of and label them as Temporary. [The state of every other node is (, t).] Designate the node s as the current node Operations Research Methods 8

Step 2. Distance Value Update and Current Node Designation Update Let i be the index of the current node. (1) Find the set J of nodes with temporary labels that can be reached from the current node i by a link (i, j). Update the distance values of these nodes. For each j J, the distance value d j of node j is updated as follows new d j = min{d j, d i + c ij } where c ij is the cost of link (i, j), as given in the network problem. (2) Determine a node j that has the smallest distance value d j among all nodes j J, find j such that d j = d j min j J (3) Change the label of node j to permanent and designate this node as the current node. Operations Research Methods 9

Step 3. Termination Criterion Lecture 18 If all nodes that can be reached from node s have been permanently labeled, then stop - we are done. If we cannot reach any temporary labeled node from the current node, then all the temporary labels become permanent - we are done. Otherwise, go to Step 2. Operations Research Methods 10

Dijkstra s Algorithm: Example We want to find the shortest path from node 1 to all other nodes using Dijkstra s algorithm. Operations Research Methods 11

Initialization - Step 1 Node 1 is designated as the current node The state of node 1 is (0, p) Every other node has state (, t) Operations Research Methods 12

Step 2 Nodes 2, 3,and 6 can be reached from the current node 1 Update distance values for these nodes d 2 = min{, 0 + 7} = 7 d 3 = min{, 0 + 9} = 9 d 6 = min{, 0 + 14} = 14 Now, among the nodes 2, 3, and 6, node 2 has the smallest distance value The status label of node 2 changes to permanent, so its state is (7, p), while the status of 3 and 6 remains temporary Node 2 becomes the current node Operations Research Methods 13

Step 3 Graph at the end of Step 2 We are not done, not all nodes have been reached from node 1, so we perform another iteration (back to Step 2) Operations Research Methods 14

Another Implementation of Step 2 Nodes 3 and 4 can be reached from the current node 2 Update distance values for these nodes d 3 = min{9, 7 + 10} = 9 d 6 = min{, 7 + 15} = 22 Now, between the nodes 3 and 4 node 3 has the smallest distance value The status label of node 3 changes to permanent, while the status of 6 remains temporary Node 3 becomes the current node We are not done (Step 3 fails), so we perform another Step 2 Operations Research Methods 15

Another Step 2 Nodes 6 and 4 can be reached from the current node 3 Update distance values for them d 4 = min{22, 9 + 11} = 20 d 6 = min{14, 9 + 2} = 11 Now, between the nodes 6 and 4 node 6 has the smallest distance value The status label of node 6 changes to permanent, while the status of 4 remains temporary Node 6 becomes the current node We are not done (Step 3 fails), so we perform another Step 2 Operations Research Methods 16

Another Step 2 Node 5 can be reached from the current node 6 Update distance value for node 5 d 5 = min{, 11 + 9} = 20 Now, node 5 is the only candidate, so its status changes to permanent Node 5 becomes the current node From node 5 we cannot reach any other node. permanently labeled and we are done. Hence, node 4 gets Operations Research Methods 17

Chapter 6.3.2 in your book has another example of the implementation of Dijkstra s algorithm Operations Research Methods 18