All-Pairs Shortest Paths Given: Digraph G=(V,E), where V={1,2,,n} , - - PDF document

all pairs shortest paths
SMART_READER_LITE
LIVE PREVIEW

All-Pairs Shortest Paths Given: Digraph G=(V,E), where V={1,2,,n} , - - PDF document

Lecture 11 Monday, June 12, 2017 11:10 PM All-Pairs Shortest Paths Given: Digraph G=(V,E), where V={1,2,,n} , possibly negative costs c(i,j), BUT no negative cycles! ( c(i,j) = means no edge (i,j) in G ) Compute: D(i,j) = cost of


slide-1
SLIDE 1

All-Pairs Shortest Paths

Given: Digraph G=(V,E), where V={1,2,…,n}, possibly negative costs c(i,j), BUT no negative cycles! ( c(i,j) = means no edge (i,j) in G ) Compute: D(i,j) = cost of cheapest path from i to j, for all i,j in V. Later, will also want an algorithm that, given (i,j), finds a cheapest path from i to j. Observation: Every cheapest path from i to j must be simple, i.e., with no cycles!

Floyd-Warshall DP algorithm

Step 1: Array Step 2: Recurrence

Lecture 11

Monday, June 12, 2017 11:10 PM slide_11 Page 1

slide-2
SLIDE 2

Step 3: Algorithm to fill in the array. Step 4: Recover shortest paths from the array

slide_11 Page 2

slide-3
SLIDE 3

slide_11 Page 3

slide-4
SLIDE 4

slide_11 Page 4

slide-5
SLIDE 5

slide_11 Page 5

slide-6
SLIDE 6

slide_11 Page 6

slide-7
SLIDE 7

slide_11 Page 7

slide-8
SLIDE 8

slide_11 Page 8

slide-9
SLIDE 9

slide_11 Page 9

slide-10
SLIDE 10

slide_11 Page 10