efficient maximum flow algorithm
play

EFFICIENT MAXIMUM FLOW ALGORITHM Nikolay Sakharnykh Hugo Braun; May - PowerPoint PPT Presentation

EFFICIENT MAXIMUM FLOW ALGORITHM Nikolay Sakharnykh Hugo Braun; May 10, 2017 MAXIMUM FLOW Definition Example : How much instant power can Palo Alto get using that electric grid? s 30 25 Power SF plant 1 8 20 Directed graph


  1. EFFICIENT MAXIMUM FLOW ALGORITHM Nikolay Sakharnykh – Hugo Braun; May 10, 2017

  2. MAXIMUM FLOW Definition Example : How much instant power can Palo Alto get using that electric grid? s 30 25 Power SF plant 1 8 20 Directed graph • • Flow capacities on edges +∞ SJ PA t Maximum flow from s to t ? • 12 2

  3. MAXIMUM FLOW Applications Image segmentation Community detection 3

  4. MAXIMUM FLOW SOLVERS AUGMENTING PREFLOW OTHER PATHS Iteratively find a new Push flow locally in a Linear programming augmenting path preflow graph Ford – Fulkerson Push relabel and its • • variants Edmonds – Karp • • Dinic’s /MPM 4

  5. Edmonds-Karp AGENDA Push-relabel MPM 5

  6. FORD FULKERSON Workflow s 1 1 while a path p of capacity c > 0 exists from s to t: a b maxflow += c 3 3 for all edges in path p: 1 edge.capacity -= c c d add reverse edge from edge.destination to edge.source of capacity c 1 5 t Augmenting path on first iteration, path of capacity min(1,3,1) = 1 6

  7. FORD FULKERSON Workflow 1 s 1 while a path p of capacity c > 0 exists from s to t: a b maxflow += c 2 3 for all edges in path p: 1 edge.capacity -= c 1 c d add reverse edge from edge.destination to edge.source of capacity c 5 t 1 Augmenting path on first iteration, path of capacity min(1,3,1) = 1 7

  8. FORD FULKERSON Workflow 1 s 1 while a path p of capacity c > 0 exists from s to t: a b maxflow += c 2 3 for all edges in path p: 1 edge.capacity -= c 1 c d add reverse edge from edge.destination to edge.source of capacity c 5 t 1 Augmenting path on first iteration, path of capacity min(1,3,1) = 1 Augmenting path on second iteration, path of capacity min(1,1,1,3,5) = 1 8

  9. EDMONDS-KARP 1 s 1 Edmonds-Karp : variation of Ford Fulkerson a b Main idea: use the shortest augmenting path 2 3 1 One augmenting path needs one BFS 1 c d Wikipedia graph: ~5000 augmenting paths 5 t 1 Ford-Fulkerson & variants use too many graph traversals 9

  10. PUSH-RELABEL 10

  11. PUSH-RELABEL Workflow Saturate all out-edges of s, create reverse edges l=? s 𝓂 [ s ] = number of vertices 𝓂 [v] = 0 for all v ∈ V \ {s} while there is an applicable push or relabel operation 1 1 execute the operation push ( u , v ): l=? l=? b a if(e [ u ] > 0 and 𝓂 [ u ] == 𝓂 [ v ] + 1 ) e=? e=? push e[u] amount of flow from u to v 1 relabel(u): if(e[u] > 0 and 𝓂 [u] <= 𝓂 [v] for all current neighbors) l=? 𝓂 [u] = minimum 𝓂 [v] among neighbors + 1 d e=? 11

  12. PUSH-RELABEL Workflow Saturate all out-edges of s, create reverse edges l=6 s 𝓂 [ s ] = number of vertices 𝓂 [v] = 0 for all v ∈ V \ {s} 1 1 while there is an applicable push or relabel operation execute the operation push ( u , v ): l=0 l=0 b a if(e [ u ] > 0 and 𝓂 [ u ] == 𝓂 [ v ] + 1 ) e=1 e=1 push e[u] amount of flow from u to v 1 relabel(u): if(e[u] > 0 and 𝓂 [u] <= 𝓂 [v] for all current neighbors) l=0 𝓂 [u] = minimum 𝓂 [v] among neighbors + 1 d e=0 12

  13. PUSH-RELABEL Workflow Saturate all out-edges of s, create reverse edges l=6 s 𝓂 [ s ] = number of vertices 𝓂 [v] = 0 for all v ∈ V \ {s} 1 1 while there is an applicable push or relabel operation execute the operation push ( u , v ): l=1 l=0 b a if(e [ u ] > 0 and 𝓂 [ u ] == 𝓂 [ v ] + 1 ) e=1 e=1 push e[u] amount of flow from u to v 1 relabel(u): if(e[u] > 0 and 𝓂 [u] <= 𝓂 [v] for all current neighbors) l=0 𝓂 [u] = minimum 𝓂 [v] among neighbors + 1 d e=0 13

  14. PUSH-RELABEL Workflow Saturate all out-edges of s, create reverse edges l=6 s 𝓂 [ s ] = number of vertices 𝓂 [v] = 0 for all v ∈ V \ {s} 1 1 while there is an applicable push or relabel operation execute the operation push ( u , v ): l=1 l=0 b a if(e [ u ] > 0 and 𝓂 [ u ] == 𝓂 [ v ] + 1 ) e=0 e=1 push e[u] amount of flow from u to v relabel(u): 1 if(e[u] > 0 and 𝓂 [u] <= 𝓂 [v] for all current neighbors) l=0 𝓂 [u] = minimum 𝓂 [v] among neighbors + 1 d e=1 14

  15. PUSH-RELABEL Parallelism issues Source of parallelism: l=6 s while there is an applicable push or relabel operation 1 1 execute the operation At this step, we could relabel a or d . Which one? l=1 l=0 b a e=0 e=1 Complexity of heuristics : 1 PRIORITY LARGEST L SMALLEST L FIFO l=0 O ( V 2 √ E ) O ( V 2 E ) O ( V 3 ) Complexity d e=1 Order affects convergence. Massive parallelism yields random order 15

  16. PUSH-RELABEL Parallelism issues In theory, number of threads = number of vertices In practice, number of active vertices << number of vertices Source : The University of Texas at Austin Parallelism drops. Not enough to saturate the GPU 16

  17. PUSH-RELABEL Conclusion l=6 s • Actual parallelism is low 1 1 • Massive parallelism yields random order which damages performance l=1 l=0 b a e=0 e=1 We need graph traversals (BFS) for some critical • heuristics 1 l=0 d e=1 road_usa : GPU does 20 BFS, CPU does only 3 BFS CPU is faster since it requires fewer traversals Push-relabel not suited for GPU implementation 17

  18. MPM 18

  19. DINIC’S Workflow s 1 2 Two augmenting paths of length 3 a b They have been discovered using just one BFS 3 3 1 Avoid running BFS twice here c d Main idea of Dinic’s : reuse BFS results 1 2 t Edges on paths of length 3 19

  20. DINIC’S Workflow s While s is still connected to t in G, do Create layer graph G L containing only 1 2 shortest paths from s to t While s is still connected to t, do a b Find augmenting path from s to t in G L 3 3 Push corresponding flow in G L , update edges 1 c d 1 2 t Graph G 20

  21. DINIC’S Workflow s While s is still connected to t in G, do Create layer graph G L containing only 2 shortest paths from s to t While s is still connected to t, do a b Find augmenting path from s to t in G L 3 3 Push corresponding flow in G L , update edges c d 1 2 t Graph G L(3) 21

  22. DINIC’S Workflow 2 s While s is still connected to t in G, do Create layer graph G L containing only shortest paths from s to t 1 While s is still connected to t, do a b 1 Find augmenting path from s to t in G L 2 2 Push corresponding flow in G L , update edges c d 1 DFS 1 t 1 Graph G L(3) 22

  23. DINIC’S Workflow s While s is still connected to t in G, do Create layer graph G L containing only 1 shortest paths from s to t While s is still connected to t, do a b 1 Find augmenting path from s to t in G L 2 Push corresponding flow in G L , update edges 1 c d 1 t Graph G L(4) 23

  24. DINIC’S Workflow 1 s While s is still connected to t in G, do Create layer graph G L containing only shortest paths from s to t 1 While s is still connected to t, do a b Find augmenting path from s to t in G L 1 Push corresponding flow in G L , update edges c d 1 1 DFS t 1 DFS traverse all vertices on GPU We lose all advantages of Dinic’s Graph G L(4) 24

  25. MPM Workflow s While s is still connected to t in G, do Create layer graph G L containing only 1 2 shortest paths from s to t While s is still connected to t, do a b Find vertex u with minimum potential m, with 3 3 potential(u) = min(degree in (u), degree out (u)) 1 push m from u to t , pull m from s to u c d remove all vertex with min(degree in (u), degree out (u))=0 1 2 t Graph G 25

  26. MPM Workflow s While s is still connected to t in G, do Create layer graph G L containing only 2 shortest paths from s to t While s is still connected to t, do b Find vertex u with minimum potential m, with 3 3 potential(u) = min(degree in (u), degree out (u)) push m from u to t , pull m from s to u c d remove all vertex with min(degree in (u), degree out (u))=0 1 2 t Graph G 26

  27. MPM Workflow s While s is still connected to t in G, do Create layer graph G L containing only 2 shortest paths from s to t While s is still connected to t, do b Find vertex u with minimum potential m, with 3 3 potential(u) = min(degree in (u), degree out (u)) push m from u to t , pull m from s to u c d remove all vertex with min(degree in (u), degree out (u))=0 1 2 t c is selected so that we know 1 amount of flow will pass through Graph G L(3) 27

  28. MPM Workflow s While s is still connected to t in G, do Create layer graph G L containing only 1 shortest paths from s to t While s is still connected to t, do b Find vertex u with minimum potential m, with 2 3 potential(u) = min(degree in (u), degree out (u)) push m from u to t, pull m from s to u c d remove all vertex with min(degree in (u), degree out (u))=0 2 t c is selected so that we know 1 amount of flow will pass through Graph G L(3) 28

  29. MPM Workflow s While s is still connected to t in G, do Create layer graph G L containing only 1 shortest paths from s to t While s is still connected to t, do b Find vertex u with minimum potential m, with 3 potential(u) = min(degree in (u), degree out (u)) push m from u to t, pull m from s to u d remove all vertex with min(degree in (u), degree out (u))=0 2 t Graph G L(3) 29

  30. MPM Dinic’s vs MPM Dinic’s - DFS MPM – Push/Pull/Prune s h 3 4 3 7 5 3 1 a b c d d c t 3 2 4 3 2 7 3 h e f g s 1 Across the graph, min potential = 1 (vertex h) t Pushing 1 to t, pulling 1 from s, using any edges Processed but useless edges Processed and acceptable edges 30

Recommend


More recommend