cse633
TRANSCRIPT
![Page 1: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/1.jpg)
Parallel Implementation of Dijkstra’s and Bellman Ford Algorithm
Team 26 B● Priyanka Ramanuja Kulkarni● Meenakshi Muthuraman● Aslesha Pansare● Nikhil Kataria
![Page 2: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/2.jpg)
Single Source Shortest Path Problem
● The Problem of finding the
shortest path from a source vertexS to all vertices in the graph● Weighted graph G = (V,E) ● Distance from S to all the
vertices
![Page 3: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/3.jpg)
Dijkstra’s Algorithm
● Solution to single source shortest path algorithm in graph theory○ Both directed and
undirected graphs○ All edges must have non-
negative weights○ Graph must be connected○ Dijkstra’s algorithm runs in
O(E*lg|V|)
![Page 4: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/4.jpg)
Pseudocode of Dijkstra’s Algorithm
![Page 5: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/5.jpg)
Negative Cycles
A negative cycle is a cycle in a weighted graph whose total weight is negative
![Page 6: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/6.jpg)
Bellman Ford’s Algorithm
BELLMAN-FORD(G,w,s)
1. INITIALIZE-SINGLE-SOURCE(G,s)
2. for i = 1 to |G.V|-1
3. for each edge (u,v) ∈ G.E
4. RELAX(u,v,w)
5. for each edge (u,v) ∈ G.E
6. if v.d > u.d + w(u,v)
7. return FALSE
8. return TRUE
BELLMAN-FORD(G,w,s)
1. INITIALIZE-SINGLE-SOURCE(G,s)
2. for i = 1 to |G.V|-1
3. for each edge (u,v) ∈ G.E
4. RELAX(u,v,w)
5. for each edge (u,v) ∈ G.E
6. if v.d > u.d + w(u,v)
7. return FALSE
8. return TRUE
● Worst case performance - 0 (|V||E|)● Space Complexity - 0(|V|)
![Page 7: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/7.jpg)
Comparing Sequential performance
![Page 8: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/8.jpg)
Assumptions
● All the edges are undirected● We consider a sparse matrix for the initial distance
vector ● Each vertex is connected to at least 1 other vertex● The weights of the edges are assigned randomly with a
restriction on the x-axis rand()
![Page 9: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/9.jpg)
Parallel Dijkstra’s Algorithm
● On each cluster identify vertices closest to the source vertex
● Use parallel prefix to select the globally closest vertex● Broadcast the results to all cores● On each cluster update the distance vectors● Running time = 0(V2/P + V*log(P))
![Page 10: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/10.jpg)
Parallel Approach
1.Allocate
graph nodes todifferent processors.
2.Shortest distance is
computed using
parallel prefix.
3. Broadcast the
Result to all nodes after finding
closest path.
❏ MPI_Reduce(MPI_IN_PLACE,nextAN,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD);❏ MPI_Bcast( G->node[0], G->N*G->N, MPI_CHAR, 0, MPI_COMM_WORLD);
![Page 11: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/11.jpg)
Dijkstra’s sequential Vs Parallel Implementation
![Page 12: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/12.jpg)
Dijkstra’s: #nodes v/s Running time
![Page 13: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/13.jpg)
Djikstra’s: Speed up
![Page 14: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/14.jpg)
Dijkstra’s: Cost Analysis
![Page 15: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/15.jpg)
Bellman Ford: sequential vs parallel
![Page 16: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/16.jpg)
Bellman Ford: Running Time v/s # of Nodes
![Page 17: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/17.jpg)
Bellman Ford: Speedup
![Page 18: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/18.jpg)
Bellman Ford: Cost Analysis
![Page 19: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/19.jpg)
Comparing parallel performance
![Page 20: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/20.jpg)
References
● Implementing Parallel Shortest-Paths Algorithms (1994) by by Marios Papaefthymiou and Joseph Rodrigue
● Algorithms Sequential & Parallel: A Unified Approach / Edition 2 by Russ Miller and Lawrence Boxer
● An Experimental Study of a Parallel Shortest Path Algorithm for Solving Large-Scale Graph Instances by Kamesh Madduri and David A. Bader, Georgia Institute of Technology and Jonathan W. Berry Sandia National Laboratories and Joseph R. Crobak, Rutgers University
● Parallel Algorithms by Guy E. Blelloch and Bruce M. Maggs, School of Computer Science, Carnegie Mellon University
![Page 21: CSE633](https://reader035.vdocuments.pub/reader035/viewer/2022081404/55892cd3d8b42a3b388b456e/html5/thumbnails/21.jpg)