SlideShare une entreprise Scribd logo
1  sur  25
25.All-Pairs Shortest Paths ,[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],25.All-Pairs Shortest Paths
[object Object],[object Object],[object Object],25.All-Pairs Shortest Paths
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.All-Pairs Shortest Paths
[object Object],[object Object],[object Object],[object Object],[object Object],25.1 Shortest paths and matrix multiplication
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.1 Shortest paths and matrix multiplication 需要花 Θ (n 3 ) 的時間
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.1 Shortest paths and matrix multiplication
25.1 Shortest paths and matrix multiplication 3 4 8 1 -5 7 2 6 -4
[object Object],[object Object],25.1 Shortest paths and matrix multiplication
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.1 Shortest paths and matrix multiplication
[object Object],[object Object],[object Object],Exercise 25.1
[object Object],[object Object],[object Object],[object Object],[object Object],25.2 The Floyd-Warshall algorithm
[object Object],[object Object],25.2 The Floyd-Warshall algorithm p 1 p 2
[object Object],[object Object],[object Object],[object Object],[object Object],25.2 The Floyd-Warshall algorithm
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.2 The Floyd-Warshall algorithm
25.2 The Floyd-Warshall algorithm 3 4 8 1 -5 7 2 6 -4 π ij (0)  = NIL if i = j or w ij  =  ∞ π ij (0)  = i if i ≠ j and  w ij  < ∞ π ij (k)  = π ij (k-1)  if d ij (k-1)  ≤ d ik (k-1)  + d kj (k-1) π ij (k)  = π kj (k-1)  if d ij (k-1)  > d ik (k-1)  + d kj (k-1)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.2 The Floyd-Warshall algorithm
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],25.2 The Floyd-Warshall algorithm
[object Object],[object Object],[object Object],Exercise 25.2
[object Object],[object Object],[object Object],[object Object],[object Object],25.3 Johnson's algorithm for sparse graphs
[object Object],[object Object],25.3 Johnson's algorithm for sparse graphs
[object Object],[object Object],25.3 Johnson's algorithm for sparse graphs 3 4 8 1 -5 7 2 6 -4 1 2 3 4 5 0 0 0 0 0 0 -4 0 -1 -5 0
[object Object],25.3 Johnson's algorithm for sparse graphs 3 4 8 1 -5 7 2 6 -4 0 0 0 0 0 1 2 3 4 5 -4 0 -1 -5 0 4 0 13 0 0 10 2 2 0 0 5 1 0 4 0 1 2 3 4 5 -4 0 -1 -5 0
[object Object],25.3 Johnson's algorithm for sparse graphs 4 0 13 0 0 10 2 2 0 1 2 3 4 5 4 0 13 0 0 10 2 2 0 0 5 1 0 4 0 1 2 3 4 5 -4 0 -1 -5 0 0/0 2/1 2/-3 2/2 0/-4 2/3 0/0 0/-4 2/6 2/-1 2/7 0/4 0/0 0/5 2/3 2/2 0/-1 0/-5 0/0 2/-2 4/8 2/5 2/1 2/6 0/0
25.3 Johnson's algorithm for sparse graphs ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraRoshan Tailor
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Traian Rebedea
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentationSubid Biswas
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Treezhaokatherine
 
Rabin Karp Algorithm
Rabin Karp AlgorithmRabin Karp Algorithm
Rabin Karp AlgorithmSohail Ahmed
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraguest1f4fb3
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treeoneous
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithmsAyesha Tahir
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithmfaisal2204
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmArijitDhali
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 
Floyd warshall algorithm
Floyd warshall algorithmFloyd warshall algorithm
Floyd warshall algorithmA. S. M. Shafi
 

Tendances (20)

SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
BFS
BFSBFS
BFS
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
 
Minimum spanning Tree
Minimum spanning TreeMinimum spanning Tree
Minimum spanning Tree
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Minimum Spanning Tree
Minimum Spanning TreeMinimum Spanning Tree
Minimum Spanning Tree
 
Rabin Karp Algorithm
Rabin Karp AlgorithmRabin Karp Algorithm
Rabin Karp Algorithm
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
 
DS ppt
DS pptDS ppt
DS ppt
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithms
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
 
Floyd warshall algorithm
Floyd warshall algorithmFloyd warshall algorithm
Floyd warshall algorithm
 

En vedette

Lec1 Algorthm
Lec1 AlgorthmLec1 Algorthm
Lec1 Algorthmhumanist3
 
Santosh Sahu_MTech_CSE
Santosh Sahu_MTech_CSESantosh Sahu_MTech_CSE
Santosh Sahu_MTech_CSESantosh Sahu
 
lecture 21
lecture 21lecture 21
lecture 21sajinsc
 
Introduction to the Internet of Things
Introduction to the Internet of ThingsIntroduction to the Internet of Things
Introduction to the Internet of Thingsardiri
 
Greedy algo revision 2
Greedy algo revision 2Greedy algo revision 2
Greedy algo revision 2maamir farooq
 
Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorthhumanist3
 
Big data lecture notes
Big data lecture notesBig data lecture notes
Big data lecture notesMohit Saini
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahniHitesh Wagle
 
Computer Networks Lecture Notes
Computer Networks Lecture NotesComputer Networks Lecture Notes
Computer Networks Lecture NotesFellowBuddy.com
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 

En vedette (20)

Lec32
Lec32Lec32
Lec32
 
Lec1 Algorthm
Lec1 AlgorthmLec1 Algorthm
Lec1 Algorthm
 
Santosh Sahu_MTech_CSE
Santosh Sahu_MTech_CSESantosh Sahu_MTech_CSE
Santosh Sahu_MTech_CSE
 
Mk ppt chapter 5
Mk ppt chapter 5Mk ppt chapter 5
Mk ppt chapter 5
 
chapter24.ppt
chapter24.pptchapter24.ppt
chapter24.ppt
 
lecture 21
lecture 21lecture 21
lecture 21
 
Introduction to the Internet of Things
Introduction to the Internet of ThingsIntroduction to the Internet of Things
Introduction to the Internet of Things
 
Lecture2
Lecture2Lecture2
Lecture2
 
Greedy algo revision 2
Greedy algo revision 2Greedy algo revision 2
Greedy algo revision 2
 
Lec2 Algorth
Lec2 AlgorthLec2 Algorth
Lec2 Algorth
 
Advance Network Technologies
Advance Network TechnologiesAdvance Network Technologies
Advance Network Technologies
 
Big data lecture notes
Big data lecture notesBig data lecture notes
Big data lecture notes
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
 
Computer Networks Lecture Notes
Computer Networks Lecture NotesComputer Networks Lecture Notes
Computer Networks Lecture Notes
 
The selection sort algorithm
The selection sort algorithmThe selection sort algorithm
The selection sort algorithm
 
6lowpan
6lowpan6lowpan
6lowpan
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary search
Binary searchBinary search
Binary search
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Selection sort
Selection sortSelection sort
Selection sort
 

Similaire à Chapter25

Acm图论
Acm图论Acm图论
Acm图论also24
 
Sect14 1
Sect14 1Sect14 1
Sect14 1F.l. Yu
 
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptxyantingguo2008
 
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论对偶分解与拉格朗日松弛在自然语言处理推理的应用导论
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论zhaoweihb
 

Similaire à Chapter25 (6)

Acm图论
Acm图论Acm图论
Acm图论
 
Part 6 2010
Part 6 2010Part 6 2010
Part 6 2010
 
Sect14 1
Sect14 1Sect14 1
Sect14 1
 
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx
福建省福州大学2019年暑假物理竞赛夏令营-物理奥赛进阶之路:0-1+微积分初步+40张ppt.pptx
 
Chapter01
Chapter01Chapter01
Chapter01
 
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论对偶分解与拉格朗日松弛在自然语言处理推理的应用导论
对偶分解与拉格朗日松弛在自然语言处理推理的应用导论
 

Chapter25

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. 25.1 Shortest paths and matrix multiplication 3 4 8 1 -5 7 2 6 -4
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. 25.2 The Floyd-Warshall algorithm 3 4 8 1 -5 7 2 6 -4 π ij (0) = NIL if i = j or w ij = ∞ π ij (0) = i if i ≠ j and w ij < ∞ π ij (k) = π ij (k-1) if d ij (k-1) ≤ d ik (k-1) + d kj (k-1) π ij (k) = π kj (k-1) if d ij (k-1) > d ik (k-1) + d kj (k-1)
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.