1 / 10

Shortest Path Algorithms

Shortest Path Algorithms. Aditya Kumar Sehgal Amlan Bhattacharya. Single Source Shortest Path – Dijkstra’s Algorithm. Weighted graph G = ( V , E , w ) Find the shortest paths from a vertex v Î V to all other vertices in V Edge may represent cost, time, etc.

rvermillion
Download Presentation

Shortest Path Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shortest Path Algorithms Aditya Kumar Sehgal Amlan Bhattacharya

  2. Single Source Shortest Path – Dijkstra’s Algorithm • Weighted graph G = (V, E, w) • Find the shortest paths from a vertex vÎV to all other vertices in V • Edge may represent cost, time, etc. • Dijkstra’s algorithm incrementally finds the shortest path from s to all other vertices • greedy algorithm • similar to Prim’s algorithm for finding minimum spanning tree

  3. Single Source Shortest Path – Dijkstra’s Algorithm procedure DIJKSTRA_SSSP(V, E, w, s) begin VT := {s}; for all vÎ (V – VT) do if (s, v) exists set l[v] := w(s, v); else set l[v] := ¥; whileVT¹Vdo begin find a vertex u such that l[u] := min{l[v] | v Î (V – VT)}; VT := VTÈ {u}; for all vÎ (V – VT) do l[v] := min{l[v], l[u] + w(u, v)}; endwhile end DIJKSTRA_SSSP

  4. Parallel Formulation of Dijkstra’s Algorithm • Similar to parallel formulation of Prim’s algorithm • Let p be number of processors and n be the number of vertices • Divide V into p subsets using 1-D block mapping • each subset has n/p consecutive vertices • work associated with each subset is assigned to a different process • each process stores the part of the array l that corresponds to Vi, where Vi is the subset of vertices assigned to process Pi.

  5. Parallel Formulation of Dijkstra’s Algorithm • Steps • Each process computes li[u] = min{li[v] | vÎ (V – VT) ÇVi} during each iteration of the while loop • Global minimum is obtained over all li[u] by using all-to-one reduction operation and is stored in process P0 • inserted into VT at P0 • P0 broadcasts u to all processes using a one-to-all broadcast • inserted into VT at each Pi • each process updates d[v] for its local vertices • needs to store weight adjacency matrix for columns in Vi • 1-D block mapping of the adjacency matrix at each process

  6. Parallel Formulation of Dijkstra’s Algorithm • Tp = Q(n2/p) + Q(nlogp) • Ts = Q(n2) • Speedup = Q(n2)/Q((n2/p)+(nlogp)) • Efficiency = 1/(1 + Q((plogp)/n))

  7. All Pairs Shortest Paths • Weighted graph G = (V, E, w) • Find the shortest paths between all pairs of vertices vi, vjÎV such that i ¹j • output is an n x n matrix D, where each element Dij is the cost of shortest path between vi and vj

  8. All Pairs Shortest Paths – Dijkstra’s Algorithm • Previously described algorithms can be used • Source Partitioned Formulation • Uses n processes • Each process Pi finds shortest paths from vi to all other vertices using Dijkstra’s sequential SSSP • No communication required • Algorithm can use only n processes • good performance if n = Q (p) • Doesn’t work so well for p > n • Tp = Q(n2) • Speedup = Q(n3)/Q(n2) • Efficiency = Q(1)

  9. All Pairs Shortest Paths – Dijkstra’s Algorithm • Source Parallel Formulation • Major problem with source-partitioned approach is that only n processes can be used • Performance can be improved if parallel version of Dijkstra’s SSSP is used • p processes are divided into n partitions with p/n processes each (p > n) • Each of the n SSSP problems is solved by one of the partitions

  10. All Pairs Shortest Paths – Dijkstra’s Algorithm • Tp = (n3/p) + (nlogp) • Speedup = (n3)/((n3/p) + (nlogp)) • Efficiency = 1/(1 + ((plogp)/n2)) • Source-parallel technique exploits more parallelism that the source-partitioned technique • W = Knplog(p) (pTp – Ts = To) W = KW1/3plog(p) W = K3/2plog(p)3/2 • Better isoefficiency function that source-partitioned function

More Related