0% found this document useful (0 votes)
92 views

Parallel Processing Floyd's Algorithm

The document discusses Floyd's algorithm, an all-pairs shortest path algorithm that uses dynamic programming to find shortest paths between all pairs of vertices in a weighted graph. It provides examples of applying the algorithm to find shortest paths in different graphs by representing the graphs as matrices and updating the matrices through iterations until the final matrix contains the shortest distances between all pairs of vertices. The algorithm can be used to find both positive and negative edge weights but not negative cycles.

Uploaded by

omar alani
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Parallel Processing Floyd's Algorithm

The document discusses Floyd's algorithm, an all-pairs shortest path algorithm that uses dynamic programming to find shortest paths between all pairs of vertices in a weighted graph. It provides examples of applying the algorithm to find shortest paths in different graphs by representing the graphs as matrices and updating the matrices through iterations until the final matrix contains the shortest distances between all pairs of vertices. The algorithm can be used to find both positive and negative edge weights but not negative cycles.

Uploaded by

omar alani
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lec.4 Parallel Processing Assistant. Lec.

Mays Afif

Parallel Processing
Floyd's Algorithm

1. Floyd-Warshall Shortest Path Algorithm


The Floyd-Warshall algorithm is an all-pair shortest paths algorithm, let
G=(V,E), be a directed graph with V vertices, then we can solve all-pair shortest
path by the Floyd-Warshall algorithm using a dynamic programming
approach on a directed graph. We store the nodes and edges of the graph in a
matrix form. The vertices of the graph are represented by the unique indices
along (nxn) matrix
(n:represents the number of nodes). The unique indices along (nxn) matrix .
Lec.4 Parallel Processing Assistant. Lec. Mays Afif

College of Engineering / Network Engineering Department 1


Lec.4 Parallel Processing Assistant. Lec. Mays Afif
Lec.4 Parallel Processing Assistant. Lec. Mays Afif

Example 1: Find the shortest path in figure 1 , using Floyd-Warshall algorithm.

College of Engineering / Network Engineering Department 3


Lec.4 Parallel Processing Assistant. Lec. Mays Afif

Example 2: Find the shortest path in figure 2 , using Floyd-Warshall algorithm.

1
8
1
4 K
4 2
2
J
I
9 1

1 2 3 4 1 2 3 4
D0 D1
1 0 8 ∞ 1 1 0 8 ∞ 1
2 ∞ 0 1 ∞ 2 ∞ 0 1 ∞ 3-1-4
3 4 ∞ 0 ∞ 3-1-2 3 4 12 0 5
4 ∞ 2 9 0 4 ∞ 2 9 0

1 2 3 4
D2 1-2-3
D3 1 2 3 4
1 0 8 9 1 1 0 8 9 1
2 ∞ 0 1 ∞
2 5 0 1 6
3 4 12 0 5 4-2-3 3 4 12 0 5
4 ∞ 2 3 0 4 7 2 3 0

2-3-1
4-3-1
4-2-3-1
2-3-1-4
Lec.4 Parallel Processing Assistant. Lec. Mays Afif

D4 1 2 3 4
1 0 3 4 1
2 5 0 1 6 1-4-3
1-4-2
3 4 7 0 5
1-4-2-3
4 7 2 3 0 3-1-4-2

The last table is final and have a shortest path of all node.

Also we can mean by the Floyd–Warshall algorithm : is an algorithm for finding


shortest paths in a weighted graph with positive or negative edge weights (but with
no negative cycles). A single execution of the algorithm will find the lengths
(summed weights) of the shortest paths between all pairs of vertices, though it
does not return details of the paths themselves. Versions of the algorithm can also
be used for finding the transitive closure of a relation R, or (in connection with the
Schulze voting system) widest paths between all pairs of vertices in a weighted
graph.

College of Engineering / Network Engineering Department 5

You might also like