Single Source Shortest Paths (SSSP) Directed graph Edge weights - - PowerPoint PPT Presentation

β–Ά
single source shortest paths sssp
SMART_READER_LITE
LIVE PREVIEW

Single Source Shortest Paths (SSSP) Directed graph Edge weights - - PowerPoint PPT Presentation

Single Source Shortest Paths (SSSP) Directed graph Edge weights Shortest path from to : Path = 0 , 1 , , of minimum weight () 5 3 where 0 = , = and 4 7 4 1


slide-1
SLIDE 1

Single Source Shortest Paths (SSSP)

Edge weights Directed graph Path π‘ž = 𝑀0, 𝑀1, … , 𝑀𝑙 of minimum weight π‘₯(π‘ž) Shortest path from 𝑑 to 𝑀 : where 𝑀0 = 𝑑, 𝑀𝑙 = 𝑀 and SSSP problem Compute a shortest path from source 𝑑 to all vertices 𝑀 𝑒 𝑑 𝑦 𝑨 3 7 3 4 5 6 4 7 1 1 𝑒(𝑀) = distance (i.e., shortest path weight) from 𝑑 to 𝑀 𝑧

slide-2
SLIDE 2

Single Source Shortest Paths (SSSP)

Edge weights Directed graph 𝑒 𝑑 𝑦 𝑨 3 7 3 4 5 6 4 7 1 1 Path π‘ž = 𝑀0, 𝑀1, … , 𝑀𝑙 of minimum weight π‘₯(π‘ž) Shortest path from 𝑑 to 𝑀 : where 𝑀0 = 𝑑, 𝑀𝑙 = 𝑀 and SSSP problem Compute a shortest path from source 𝑑 to all vertices 𝑀 𝑒(𝑒) = 3 𝑒(𝑧) = 4 𝑒(𝑦) = 8 𝑒(𝑧) = 10 𝑒(𝑀) = distance (i.e., shortest path weight) from 𝑑 to 𝑀 𝑧

slide-3
SLIDE 3

Single Source Shortest Paths (SSSP)

Parent of a vertex Shortest paths tree Formed by the edges (π‘ž(𝑀), 𝑀) π‘ž 𝑀 = vertex just before 𝑀 on the shortest path from 𝑑 𝑒 𝑑 𝑦 𝑨 3 7 3 4 5 6 4 7 1 1 π‘ž(𝑀) 𝑑 𝑀 π‘ž(𝑑) = - π‘ž(𝑒) = 𝑑 π‘ž(𝑦) = 𝑒 π‘ž(𝑧) = 𝑒 π‘ž(𝑨) = 𝑧 𝑧

slide-4
SLIDE 4

Single Source Shortest Paths (SSSP)

Temporary distances 𝑒(𝑀) = upper bound for the weight of the shortest path from 𝑑 to 𝑀 Initialize Edge relaxation π‘ž(𝑀) ← null, 𝑒(𝑀) ← ∞ for all 𝑀 β‰  𝑑 π‘ž(𝑑) ← null, 𝑒(𝑑) ← 0 relax(𝑣, 𝑀) if if 𝑒(𝑀) > 𝑒(𝑣) + π‘₯(𝑣, 𝑀) th then { 𝑒(𝑀) ← 𝑒(𝑣) + π‘₯(𝑣, 𝑀) π‘ž(𝑀) ← 𝑣 } 2 𝑒(𝑣) = 5 𝑣 𝑀 𝑒(𝑀) = 8 2 𝑒(𝑣) = 5 𝑣 𝑀 𝒆(π’˜) = πŸ– 2 𝑒(𝑣) = 5 𝑣 𝑀 𝑒(𝑀) = 6 2 𝑒(𝑣) = 5 𝑣 𝑀 𝑒(𝑀) = 6

slide-5
SLIDE 5

Single Source Shortest Paths (SSSP)

Dijkstra’s Algorithm Used when edge weights are non-negative It maintains a set of vertices 𝑇 βŠ† π‘Š for which a shortest path has been computed, i.e., the value of 𝑒(𝑀) is the exact weight of the shortest path to 𝑀. Each iteration selects a vertex 𝑣 ∈ π‘Š\S with minimum distance 𝑒(𝑣). Then we set S ← 𝑇 βˆͺ 𝑣 and relax all edges (𝑣, π‘₯) To find 𝑣 with min 𝑒(𝑣): Use a priority queue 𝑅 with keys

slide-6
SLIDE 6

Single Source Shortest Paths (SSSP)

Dijkstra’s Algorithm Initialization π‘ž(𝑀) ← null, 𝑒(𝑀) ← ∞ for all 𝑀 β‰  𝑑 π‘ž(𝑑) ← null, 𝑒(𝑑) ← 0 insert all vertices 𝑀 into priority queue 𝑅 with key 𝑒(𝑀) set 𝑇 ← βˆ… Main Loop while 𝑅 is not empty { 𝑣 ← Q. delMin() 𝑇 ← 𝑇 βˆͺ 𝑣 for all edges (𝑣, 𝑀) { relax(𝑣, 𝑀) } }

slide-7
SLIDE 7

Single Source Shortest Paths (SSSP)

Dijkstra’s Algorithm Initialization π‘ž(𝑀) ← null, 𝑒(𝑀) ← ∞ for all 𝑀 β‰  𝑑 π‘ž(𝑑) ← null, 𝑒(𝑑) ← 0 insert all vertices 𝑀 into priority queue 𝑅 with key 𝑒(𝑀) set 𝑇 ← βˆ… Main Loop while 𝑅 is not empty { 𝑣 ← Q. delMin() 𝑇 ← 𝑇 βˆͺ 𝑣 for all edges (𝑣, 𝑀) { relax(𝑣, 𝑀) } } priority queue 𝑅 running time array O(π‘œ2) binary heap O(𝑛 log π‘œ) Fibonacci heap O(𝑛 + π‘œ log π‘œ)

slide-8
SLIDE 8

Single Source Shortest Paths (SSSP) in Map-Reduce

➒ Not easy to parallelize Dijkstra’s algorithm ➒ Use an iterative approach instead

  • The distance 𝑒(𝑀) from 𝑑 to 𝑀 is updated by the distances of all 𝑣 with

𝑣, 𝑀 ∈ 𝐹.

  • Need to communicate both distances and adjacency lists.

𝑧 𝑦 𝑀 π‘₯(𝑦, 𝑀) 𝑨 π‘₯(𝑧, 𝑀) π‘₯(𝑨, 𝑀) 𝑒(𝑀) ← min 𝑒 𝑣 + π‘₯ 𝑣, 𝑀 | (𝑣, 𝑀) ∈ 𝐹

slide-9
SLIDE 9

Single Source Shortest Paths (SSSP) in Map-Reduce

Mapper: emits distances and graph structure 𝑧 𝑦 𝑀 π‘₯(𝑦, 𝑀) 𝑨 π‘₯(𝑧, 𝑀) π‘₯(𝑨, 𝑀) 𝑒(𝑀) ← min 𝑒 𝑣 + π‘₯ 𝑣, 𝑀 | (𝑣, 𝑀) ∈ 𝐹 Reducer: updates distances and emits graph structure 𝑏 𝑐 𝑀 𝑑 𝑒 𝑀 + π‘₯(𝑀, 𝑏) 𝑒 𝑀 + π‘₯(𝑀, 𝑐) 𝑒 𝑀 + π‘₯(𝑀, 𝑑)

slide-10
SLIDE 10

Single Source Shortest Paths (SSSP) in Map-Reduce

➒ Not easy to parallelize Dijkstra’s algorithm ➒ Use an iterative approach instead

  • The distance 𝑒(𝑀) from 𝑑 to 𝑀 is updated by the distances of all 𝑣 with

𝑣, 𝑀 ∈ 𝐹.

  • Need to communicate both distances and adjacency lists.
  • Repeat round until all distances are fixed.
  • Number of rounds = π‘œ βˆ’ 1 in the worst case.
  • If all weights are equal then we compute the Breadth-First Search

(BFS) tree. Number of rounds = graph diameter.

slide-11
SLIDE 11

BFS in Map-Reduce

slide-12
SLIDE 12

Single Source Shortest Paths (SSSP) in Map-Reduce

Remarks on Map-Reduce SSSP algorithm

  • Essentially a brute-force algorithm.
  • Performs many unnecessary computations.
  • No global data structure.
slide-13
SLIDE 13

PageRank in Map-Reduce

Recall the formula for the PageRank 𝑆(𝑣) of a webpage 𝑣

𝑆 𝑣 = 𝑑 ෍

π‘€βˆˆπΆπ‘£

𝑆(𝑀) 𝑂𝑀 + (1 βˆ’ 𝑑)𝐹𝑣

𝐢𝑣 = set of pages that point to 𝑣 𝐺

𝑣 = set of pages that 𝑣 points to

𝐺

𝑣 = 𝑂𝑣 = number of links from 𝑣

𝐹𝑣 = probabilities over web pages 𝐹𝑣 and 𝑑 are user designed parameters

slide-14
SLIDE 14

PageRank in Map-Reduce

Iterative computation start with seed values 𝑆0(𝑀) for each page 𝑀 each page 𝑀 receives credit from the pages in 𝐢𝑀 and computes 𝑆𝑗+1(𝑀) each page 𝑀 distributes credit to the pages in 𝐺

𝑀

slide-15
SLIDE 15

PageRank in Map-Reduce

slide-16
SLIDE 16

Algorithms and Complexity in MapReduce (and related models)

Sorting, Searching, and Simulation in the MapReduce Framework

  • M. T. Goodrich, N. Sitchinava, and Q. Zhang

ISAAC 2011 Fast Greedy Algorithms in MapReduce and Streaming

  • R. Kumar, B. Moseley, S. Vassilvitskii, and A. Vattani

SPAA 2013 On the Computational Complexity of MapReduce

  • B. Fish, J. Kun, A. D. Lelkes, L. Reyzin, and G. Turan

DISC 2015

slide-17
SLIDE 17
  • L. G. Valiant, A Bridging Model for Parallel Computation,

Communications of the ACM, 1990 Computational model of parallel computation BSP is a parallel programming model based on Synchronizer Automata. The model consists of:

  • Set of processor-memory pairs.
  • Communications network that delivers messages in a point-to-point

manner.

  • Mechanism for the efficient barrier synchronization for all or a subset of

the processes.

  • No special combining, replicating, or broadcasting facilities.

BSP model

slide-18
SLIDE 18
  • Vertical Structure

Supersteps: – Local computation – Process Communication – Barrier Synchronization

  • Horizontal Structure

– Concurrency among a fixed number of virtual processors. – Processes do not have a particular order. – Locality plays no role in the placement of processes on processors.

Virtual Processors Local Computation Global Communication Barrier Synchronization

Implementation: BSPlib

BSP model

slide-19
SLIDE 19

Simulation on MapReduce: 1. Create a tuple for each memory cell and processor. 2. Map each message to the destination processor label. 3. Reduce by performing one step of a processor, outputting the messages for next round. Theorem [Goodrich et al.]: Given a BSP algorithm 𝐡 that runs in π‘ˆ supersteps with a total memory size 𝑂 using 𝑄 ≀ 𝑂 processors, we can simulate 𝐡 using O(π‘ˆ) rounds and message complexity O(π‘ˆπ‘‚) in the memory-bound MapReduce framework with reducer memory size bounded by 𝑂/𝑄.

MapReduce simulation of a BSP program

slide-20
SLIDE 20

Simulation on MapReduce: 1. Create a tuple for each memory cell and processor. 2. Map each message to the destination processor label. 3. Reduce by performing one step of a processor, outputting the messages for next round. Theorem [Goodrich et al.]: Given a BSP algorithm 𝐡 that runs in π‘ˆ supersteps with a total memory size 𝑂 using 𝑄 ≀ 𝑂 processors, we can simulate 𝐡 using O(π‘ˆ) rounds and message complexity O(π‘ˆπ‘‚) in the memory-bound MapReduce framework with reducer memory size bounded by 𝑂/𝑄. A corollary of the above: Given the optimal BSP algorithm of [Goodrich, 99], we can sort 𝑂 values in the MapReduce framework in 𝑃(𝑙) rounds and 𝑃(𝑙𝑂) message complexity.

MapReduce simulation of a BSP program

slide-21
SLIDE 21

Algorithms and Complexity in MapReduce (and related models)

Theorem [Fish et al.] : Any problem requiring sublogarithmic space, 𝑝(log π‘œ ), can be solved in MapReduce in two rounds. The proof is constructive: Given a problem that classically takes less than logarithmic space, there is an automatic algorithm to implement it in MapReduce