![]() |
![]() ![]() |
10.3 Single-Source Shortest Paths: Dijkstra's AlgorithmFor a weighted graph G = (V, E, w), the single-source shortest paths problem is to find the shortest paths from a vertex v Dijkstra's algorithm, which finds the shortest paths from a single vertex s, is similar to Prim's minimum spanning tree algorithm. Like Prim's algorithm, it incrementally finds the shortest paths from s to the other vertices of G. It is also greedy; that is, it always chooses an edge to a vertex that appears closest. Algorithm 10.2 shows Dijkstra's algorithm. Comparing this algorithm with Prim's minimum spanning tree algorithm, we see that the two are almost identical. The main difference is that, for each vertex u Algorithm 10.2 Dijkstra's sequential single-source shortest paths algorithm.1. procedure DIJKSTRA_SINGLE_SOURCE_SP(V, E, w, s) 2. begin 3. VT := {s}; 4. for all v Parallel FormulationThe parallel formulation of Dijkstra's single-source shortest path algorithm is very similar to the parallel formulation of Prim's algorithm for minimum spanning trees (Section 10.2). The weighted adjacency matrix is partitioned using the 1-D block mapping (Section 3.4.1). Each of the p processes is assigned n/p consecutive columns of the weighted adjacency matrix, and computes n/p values of the array l. During each iteration, all processes perform computation and communication similar to that performed by the parallel formulation of Prim's algorithm. Consequently, the parallel performance and scalability of Dijkstra's single-source shortest path algorithm is identical to that of Prim's minimum spanning tree algorithm. ![]() |
![]() |
![]() ![]() |