Presentation is loading. Please wait.

Presentation is loading. Please wait.

Preflow Push Algorithm M. Amber Hassaan. Preflow Push Algorithm2 Max Flow Problem Given a graph with “Source” and “Sink” nodes we want to compute:  The.

Similar presentations


Presentation on theme: "Preflow Push Algorithm M. Amber Hassaan. Preflow Push Algorithm2 Max Flow Problem Given a graph with “Source” and “Sink” nodes we want to compute:  The."— Presentation transcript:

1 Preflow Push Algorithm M. Amber Hassaan

2 Preflow Push Algorithm2 Max Flow Problem Given a graph with “Source” and “Sink” nodes we want to compute:  The maximum rate at which fluid can flow from Source to Sink  The rate of flow through each edge of the graph Given a graph:  Edges have flow capacities First value is flow capacity Second value is current flow rate  Edges behave like pipes  Nodes are junctions of pipes History:  Ford and Fulkerson 1956 (Augmenting Paths)  Dinic 1970  Edmonds and Karp 1972  Malhotra, Kumar and Maheshwari 1978  Goldberg and Tarjan 1986 (Preflow Push)  Boykov and Kolmogorov 2006 s a b t 5, 2 8, 7 4, 4 6, 2 5, 5 Min-cut

3 Preflow Push Algorithm3 Max Flow Problem Flow f(u,v) is a real-valued function defined for every edge (u,v) in the graph The flow needs to satisfy the following 3 properties:  f(u,v) ≤ c(u,v) i.e. capacity of edge (u,v)  f(u,v) = - f(v,u)  Flow coming into node v = Flow leaving v s a b t 5, 2 8, 7 4, 4 6, 2 5, 5

4 Preflow Push Algorithm4 Max Flow Problem Residual Graph:  A Graph that contains edges that can admit more flow  Define a Graph G(V,E’) for G(V,E)  We define residual flow r(u,v) = c(u,v) – f(u,v)  If r(u,v) > 0 then (u,v) is in E’ s a b t 5, 2 8, 7 4, 4 6, 2 5, 5 s a b t 2 3 1 7 4 2 4 5 Original GraphResidual Graph

5 Preflow Push Algorithm5 Preflow Push Algorithm for Maxflow problem Relaxation algorithm:  Performs local updates repeatedly until global constraint is satisfied  Similar to Stencil computations Fluid flows from a higher point to a lower point In the beginning  “Source” is the highest point  “Sink” and all other nodes are at the lowest point Source sends maximum flow on its outgoing edges  Sending flow to out-neighbors is called “Push” operation The height of Source’s neighbors is then increased so that fluid can flow out  Increasing height of a node is called “Relabel” operation

6 Preflow Push Algorithm6 Preflow Push Algorithm for Maxflow problem A node is allowed (temporarily) to have more flow coming into it than flow going out  i.e. a node can have “excess flow”  But the edges must respect the capacity condition  Source can have arbitrary amount of excess flow A node is said to be “active” if it has excess flow in it

7 Preflow Push Algorithm7 Preflow Push Algorithm for Maxflow problem We increase the height of the “active” node with a “Relabel” operation  If h is the minimum height among neighbors that can accept flow  Then height is relabeled to (h+1) Then we “push” the excess flow to the neighbors  That are lower than the active node and can admit flow  Thus make them active Algorithm terminates when there are no “active” nodes left

8 Preflow Push Algorithm8 Example A simple graph:  Nodes have two attributes: Height ‘h’ Excess flow ‘e’  Edges have pairs: First value is edge capacity Second value is flow Initialize:  s has h=6 i.e. number of nodes  Push 10 along (s,a) e(a) = 10  Push 12 along (s,c) e(c) = 12 s c ab t d h=6 h=0 e=0 h=0 e=0 h=0 e=0 h=0 e=0 h=0 e=0 10,0 12,0 5,0 8,0 15,0 6,0 17,0 3,0

9 Preflow Push Algorithm9 Example Relabel c with h=1  Push 6 along (c,d) e(d) = 6 Relabel c with h=2  Push 5 along (c,a) e(a) = 5 Relabel c with h=7  Push -1 along (s,c) s c ab t d h=6 h=0 e=10 h=0 e=10 h=0 e=0 h=1 e=12 h=0 e=0 10,10 12,12 5,0 8,0 15,0 6,0 17,0 3,0

10 Preflow Push Algorithm10 Example Relabel a with h=1  Push 15 along (a,b) e(b) = 15 s c ab t d h=6 h=1 e=15 h=0 e=0 h=0 e=0 h=7 e=0 h=0 e=5 10,10 12,11 5,5 8,0 15,0 6,6 17,0 3,0

11 Preflow Push Algorithm11 Example Relabel b with h=1  Push 3 along (b,t) e(t) = 3  Push 8 along (b,d) e(d) = 14 Relabel b with h=2  Push -4 along (a,b) e(a) = 4 s c ab t d h=6 h=1 e=0 h=1 e=15 h=0 e=3 h=7 e=0 h=0 e=6 10,10 12,11 5,5 8,0 15,15 6,6 17,0 3,0

12 Preflow Push Algorithm12 Example Relabel d with h=1  Push 14 along (d,t) e(t) = 17 s c ab t d h=6 h=1 e=4 h=2 e=0 h=0 e=3 h=7 e=0 h=1 e=14 10,10 12,11 5,5 8,8 15,11 6,6 17,0 3,3

13 Preflow Push Algorithm13 Example Relabel a with h=3  Push 4 along (a,b) e(b) = 4 s c ab t d h=6 h=3 e=4 h=2 e=0 h=0 e=17 h=7 e=0 h=1 e=0 10,10 12,11 5,5 8,8 15,11 6,6 17,14 3,3

14 Preflow Push Algorithm14 Example Relabel b with h=4  Push -4 along (a,b) e(a) = 4 s c ab t d h=6 h=3 e=0 h=4 e=4 h=0 e=17 h=7 e=0 h=1 e=0 10,10 12,11 5,5 8,8 15,15 6,6 17,14 3,3

15 Preflow Push Algorithm15 Example Relabel a with h=5  Push 4 along (a,b) e(b) = 4 s c ab t d h=6 h=5 e=4 h=4 e=0 h=0 e=17 h=7 e=0 h=1 e=0 10,10 12,11 5,5 8,8 15,11 6,6 17,14 3,3

16 Preflow Push Algorithm16 Example Relabel b with h=6  Push -4 along (a,b) e(a) = 4 s c ab t d h=6 h=5 e=0 h=6 e=4 h=0 e=17 h=7 e=0 h=1 e=0 10,10 12,11 5,5 8,8 15,15 6,6 17,14 3,3

17 Preflow Push Algorithm17 Example Relabel a with h=7  Push -4 along (s,a) e(a) = 0 s c ab t d h=6 h=7 e=4 h=6 e=0 h=0 e=17 h=7 e=0 h=1 e=0 10,10 12,11 5,5 8,8 15,11 6,6 17,14 3,3

18 Preflow Push Algorithm18 Example No active nodes left The algorithm terminates s c ab t d h=6 h=7 e=0 h=6 e=0 h=0 e=17 h=7 e=0 h=1 e=0 10,6 12,11 5,5 8,8 15,11 6,6 17,14 3,3 Min-cut

19 Preflow Push Algorithm19 Pseudo code  Worklist wl = initializePreflowPush();  while (!wl.isEmpty()) {  Node n = wl.remove();  n.relabel();  for (Node w in n.neighbors()) {  if (n can push flow to w) {  pushflow(n, w);  wl.add(w);  }  }  if (n has excess flow) {  wl.add(n);  }  }

20 Preflow Push Algorithm20 Amorphous Data Parallelism in Preflow Push Topology: graph Operator: local computation (data driven) Active nodes: nodes with excess flow Neighborhoods: active nodes and their neighbors Ordering: unordered Parallelism: Shoots in the beginning and then drops down  Dependent on number of active nodes

21 Preflow Push Algorithm21 Parallelism profile for Preflow Push Input Graph: 512x512 Grid

22 Preflow Push Algorithm22 Preflow Push: Global Relabeling The height of the nodes directs the flow towards the sink:  It affects the flow of fluid globally  But is updated locally  Which causes the fluid to flow in arbitrary directions  Increases the total number of push/relabel operations Global Relabeling:  After every N push/relabel operations we compute the height of every node from the sink  The height is computed by a breadth-first scan on the Residual Graph starting at the sink The height is incremented at each next level of BFS  It reduces the number of push/relabel operations significantly  N is determined heuristically

23 Preflow Push Algorithm23 Preflow Push: Global Relabeling s c ab t d h=6 h=2 e=0 h=1 e=0 h=0 e=17 h=2 e=0 h=1 e=0 5 8 6 3 4 1 6 11 4 14 3

24 Preflow Push Algorithm24 Conclusion Preflow Push is an algorithm to find the max-flow in a graph It exhibits amorphous data parallelism  Parallelism is dependent on the structure of the graph


Download ppt "Preflow Push Algorithm M. Amber Hassaan. Preflow Push Algorithm2 Max Flow Problem Given a graph with “Source” and “Sink” nodes we want to compute:  The."

Similar presentations


Ads by Google