All Pair Shortest Paths Instructor Prof JyhShing Roger

  • Slides: 11
Download presentation
All Pair Shortest Paths Instructor : Prof. Jyh-Shing Roger Jang Designer:Shao-Huan Wang The ideas

All Pair Shortest Paths Instructor : Prof. Jyh-Shing Roger Jang Designer:Shao-Huan Wang The ideas are reference to the textbook “Fundamentals of Data Structures in C “.

All Pair Shortest Path Set a cost adjacency matrix, which blanks are infinite Give

All Pair Shortest Path Set a cost adjacency matrix, which blanks are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] > distance[i][k] + distance[k][j] K=1 0 LA 4 1 3 2 SF DEN CHI NY 0 250 MIA NO 900 1400 0 1000 0 300 0 1000 800 0 1200 5 0 1500 0 1000 7 BOST 6 1700 0 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=2 LA 4 1 3 2 5 SF DEN 1000+ +1200= =2000 2200< <+∞ +∞ 800 CHI NY 0 250 MIA NO 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 1500 0 1000 7 BOST 6 1700 0 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=3 LA 4 1 3 2 5 SF DEN 2200 + 1500 = 3500 2000 3700 < +∞ CHI NY 0 250 MIA NO 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 3700 3500 0 0 1500 1000 7 BOST 6 1700 0 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=3 LA 4 1 3 2 5 0 DEN CHI BOST NY 0 250 MIA NO 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3700 3500 2700 1500 3200 7 SF 1200 2200 + 1500 1000 = 2700 3200 < +∞ 6 1700 1000 0 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=3 LA 4 1 3 2 5 0 7 SF DEN 2000 + 1000 = 2200 1200 3000 < +∞ CHI BOST NY 0 250 MIA NO 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3700 3500 2700 1500 3200 3000 2200 1000 6 1700 0 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=5 4 LA 4 1 3 2 5 0 7 SF DEN 250 + 3000 3200 2200 = 3250 3450 2450 < 3500 3700 2700 CHI BOST NY MIA NO 0 250 1150 0 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3450 3700 3250 3500 2700 2450 1250 3200 3000 2200 1000 6 1700 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=5 LA 4 1 3 2 5 0 7 SF DEN 250 + 900 1000==1150 1250<<+∞ 1500 CHI BOST NY MIA NO 0 250 1150 0 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3450 3250 2450 1250 1500 3200 3000 2200 1000 6 1700 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=5 6 LA 4 1 3 2 5 0 7 SF DEN 250 + 1400 = 1650 < +∞ CHI BOST NY MIA NO 0 250 1150 1650 0 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3450 3250 2450 1250 3200 3000 2200 1000 6 1700 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=7 LA 4 1 3 2 5 0 7 SF DEN 1400 1650 + 1700 = 3100 3350 < 3200 3450 CHI BOST NY MIA NO 0 250 1150 1650 0 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3350 3450 3250 2450 1250 3200 3100 3000 2200 1000 6 1700 0

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give

All Pair Shortest Path Set a cost matrix, which blank spaces are infinite Give a variable “k” from 0 to n, change all the distance[i][j] if distance[i][j] < distance[i][k] + distance[k][j] K=7 LA 4 1 3 2 5 0 7 6 SF DEN 1000 + 1700 = 2700 < +∞ CHI BOST NY MIA NO 0 250 1150 1650 0 900 1400 0 1000 0 300 0 1000 800 0 2200 2000 1200 0 3350 3250 2450 1250 3100 3000 2200 1000 2700 1700 0