Shortest Path Problems

Slides:



Advertisements
Similar presentations
Bellman-Ford algorithm
Advertisements

Single Source Shortest Paths
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Chapter 5 Routing Algorithm in Networks. How are message routed from origin to destination? 1) Circuit-Switching → telephone net. Dedicated bandwidth.
MIT and James Orlin © Introduction to Networks Eulerian Tours Hamiltonian Tours The Shortest Path Problem Dijkstra’s Algorithm for Solving the Shortest.
1 Routing Algorithms. 2 Outline zBellaman-Ford Algorithm zDijkstra Algorithm.
Computational Methods for Management and Economics Carla Gomes
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Chapter 4 Shortest Path Label-Setting Algorithms Introduction & Assumptions Applications Dijkstra’s Algorithm.
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
Lecture 10 The Label Correcting Algorithm.
15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘length’ c ij (cost, time, distance, …). Determine a path of shortest.
EMIS 8374 Shortest Path Trees Updated 11 February 2008 Slide 1.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
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.
School of Computing Clemson University Fall, 2012
Centralized vs Distributed Routing
Shortest Paths CONTENTS Introduction to Shortest Paths (Section 4.1)
Dijkstra’s shortest path Algorithm
Network Simplex Animations
Π: nil d: 0 π: nil d: ∞ 2 A B -1 π: nil d: ∞ C D E 4 π: nil d: ∞ π: nil d: ∞
Algorithms and Data Structures Lecture XIII
Introduction to Graphs
Shortest Path Problems
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Dijkstra’s Algorithm We are given a directed weighted graph
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Introduction to Maximum Flows
Link State Route Calculations
Dijkstra’s Algorithm for the Shortest Path Problem
Dijkstra’s Algorithm for the Shortest Path Problem
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Single Source Shortest Paths Bellman-Ford Algorithm
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Shortest-Paths Trees Kun-Mao Chao (趙坤茂)
Lecture 4 Graph Search.
Algorithms and Data Structures Lecture XIII
Making Change Coins: 2 and
Shortest Path Algorithms
Link State Route Calculations
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Shortest-Path Property 4.1
Chapter 4: Finding the Shortest Path Lesson 1: Dijkstra’s Algorithm
Complexity of Ford-Fulkerson
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
The Bellman-Ford Shortest Path Algorithm Neil Tang 03/27/2008
Chapter 24: Single-Source Shortest Paths
Introduction to Algorithms
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
EMIS 8374 Search Algorithms Updated 9 February 2004
The Ford-Fulkerson Algorithm
Network Optimization Topological Ordering
and 6.855J Dijkstra’s Algorithm
Shortest Path Problems
Network Simplex Animations
Lecture 23 CSE 331 Oct 24, 2011.
Chapter 24: Single-Source Shortest Paths
15.082J & 6.855J & ESD.78J Visualizations
Implementation of Dijkstra’s Algorithm
Shortest Path Solutions
and 6.855J Depth First Search
Bellman Ford.
Prim’s algorithm for minimum spanning trees
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
EMIS 8374 Search Algorithms Updated 12 February 2008
CSCI 465 Data Communications and Networks Lecture 16
Presentation transcript:

Shortest Path Problems Bellman-Ford Algorithm for the Single-Source Shortest Path Problem with Arbitrary Arc Costs Updated 18 February 2008

Bellman-Ford Algorithm begin d(i) :=  for each node i in N d(s) := 0 and pred(s) := 0; for k = 1 to n for each (i, j) in A do if d(j) > d(i) + cij then d(j) := d(i) + cij and pred(j) := i end;

Bellman-Ford Example 1  2 2 1 4 3 -2  

dk(i) denotes d(i) after iteration k Bellman-Ford Example 1 -1   2 k =1 1 2 d1(1) = 0 d1(2) = -1 d1(3) = 4 d1(4) = 1 -2 1 1 3 4 3 4  1    dk(i) denotes d(i) after iteration k

Bellman-Ford Example 1 -1 k = 2 2 1 2 d2(1)=0 d2(2)=-1 d2(3)=0 d2(4)=1 k = 2 2 1 2 d2(1)=0 d2(2)=-1 d2(3)=0 d2(4)=1 -2 1 1 3 4 3 1  4

Bellman-Ford Example 1 -1 k =3 2 1 2 d3(1)=0 d3(2)=-1 d3(3)=0 d3(4)=1 k =3 2 1 2 d3(1)=0 d3(2)=-1 d3(3)=0 d3(4)=1 -2 1 1 3 4 3 d3(i)= d2(i) 1

Shortest Path Tree d(j)  d(i) + cij and d(j) = d(i) + cij -1 2 1 2 d(j)  d(i) + cij and d(j) = d(i) + cij for all predecessor arcs -2 1 1 3 4 3 1

Complexity of Bellman-Ford There are n iterations Each iteration inspects each arc once Inspecting an arc is O(1) Complexity is O(mn)

Bellman-Ford Example 2  100 1 2 10 200 -150 -150 4 3  

Bellman-Ford Example 2 100   100 k = 1 1 2 d1(1) = 0 d1(2) = 100  100 k = 1 1 2 d1(1) = 0 d1(2) = 100 d1(3) =  d1(4) = 200 10 -150 200 -150 4 3   200 

Bellman-Ford Example 2 -100 100 100 100 k = 2 1 2 d2(1) = 0 100 k = 2 1 2 d2(1) = 0 d2(2) = -100 d2(3) = 50 d2(4) = -90 10 -150 200 -150 4 3  100 200 -90 50 100

Bellman-Ford Example 2 -100 100 k = 3 1 2 d3(1) = 0 d3(2) = -100 100 k = 3 1 2 d3(1) = 0 d3(2) = -100 d3(3) = -240 d3(4) = -90 10 -150 200 -150 4 3 -90 -240 100 50

Bellman-Ford Example 2 -100 -390 100 k = 4 1 2 10 d4(1) = 0 -150 200 -390 100 k = 4 1 2 10 d4(1) = 0 -150 200 d4(2) = -390 d4(3) = -240 -150 4 3 d4(4) = -90 -90 -240 100 d3(2) = -100

Detecting Negative-Cost Cycles If there is a negative-cost cycle in G, then dn(i) < dn-1(i) for some node i.

Detecting Negative-Cost Cycles dn-1(1) dn-1(2) 1 2 dn(4)  dn-1(1) + c14 dn(1)  dn-1(2) + c21 dn(2)  dn-1(3) + c32 4 3 dn(3)  dn-1(4) + c43 dn-1(4) dn-1(3)

Detecting Negative-Cost Cycles If the length of the cycle < 0 then dn(i) < dn-1(i) for at least one node i in the cycle.