Preflow Push Algorithm
M. Amber Hassaan
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
a
Malhotra, Kumar and Maheshwari 1978
Goldberg and Tarjan 1986 (Preflow Push)
5, 2
Boykov and Kolmogorov 2006
4, 4
6, 2
s
t
8, 7
Preflow Push Algorithm
Min-cut
5, 5
b
2
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:
≤ c(u,v) i.e. capacity of edge (u,v)
= - f(v,u)
Flow coming into node v = Flow leaving v
f(u,v)
f(u,v)
a
5, 2
4, 4
6, 2
s
t
8, 7
Preflow Push Algorithm
5, 5
b
3
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’
Original Graph
a
5, 2
Residual Graph
a
2
4
4, 4
3
6, 2
s
t
4
s
t
2
1
8, 7
5, 5
b
5
7
Preflow Push Algorithm
b
4
Preflow Push Algorithm for Maxflow problem
Relaxation algorithm:
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
Performs local updates repeatedly until global constraint is
satisfied
Similar to Stencil computations
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
Preflow Push Algorithm
5
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
Preflow Push Algorithm
6
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
Preflow Push Algorithm
7
Example
a
A simple graph:
Height ‘h’
Excess flow ‘e’
3,0
s
First value is edge capacity
Second value is flow
Initialize:
e(a) = 10
t
8,0
h=6
17,0
12,0
c
s has h=6 i.e. number of
nodes
Push 10 along (s,a)
b
5,0
Edges have pairs:
15,0
h=0
e=0
10,0
Nodes have two attributes:
h=0
e=0
h=0
e=0
6,0
h=0
e=0
d
h=0
e=0
Push 12 along (s,c)
e(c) = 12
Preflow Push Algorithm
8
Example
h=0
e=10
a
Relabel c with h=1
Push
s
5 along (c,a)
Relabel c with h=7
t
8,0
h=6
17,0
12,12
c
e(a) = 5
Push
3,0
5,0
Relabel c with h=2
b
10,10
6 along (c,d)
e(d) = 6
Push
15,0
h=0
e=10
h=1
e=12
6,0
h=0
e=0
d
h=0
e=0
-1 along (s,c)
Preflow Push Algorithm
9
Example
h=1
e=15
a
Relabel a with h=1
Push
e(b) = 15
b
10,10
3,0
15 along
(a,b)
15,0
h=0
e=0
5,5
s
t
8,0
h=6
17,0
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
h=0
e=0
d
h=0
e=5
10
Example
h=1
e=0
a
Relabel b with h=1
Push
s
t
8,0
h=6
8 along (b,d)
17,0
12,11
Relabel b with h=2
3,0
5,5
e(d) = 14
Push
b
10,10
3 along (b,t)
e(t) = 3
Push
15,15
h=1
e=15
-4 along (a,b)
c
h=7
e=0
6,6
h=0
e=3
d
h=0
e=6
e(a) = 4
Preflow Push Algorithm
11
Example
h=1
e=4
a
Relabel d with h=1
Push
b
10,10
3,3
14 along (d,t)
e(t) = 17
15,11
h=2
e=0
5,5
s
t
8,8
h=6
17,0
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
h=0
e=3
d
h=1
e=14
12
Example
h=3
e=4
a
Relabel a with h=3
Push
b
10,10
3,3
4 along (a,b)
e(b) = 4
15,11
h=2
e=0
5,5
s
8,8
h=6
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
t
h=0
17,14 e=17
d
h=1
e=0
13
Example
h=3
e=0
a
Relabel b with h=4
Push
b
10,10
3,3
-4 along (a,b)
e(a) = 4
15,15
h=4
e=4
5,5
s
8,8
h=6
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
t
h=0
17,14 e=17
d
h=1
e=0
14
Example
h=5
e=4
a
Relabel a with h=5
Push
b
10,10
3,3
4 along (a,b)
e(b) = 4
15,11
h=4
e=0
5,5
s
8,8
h=6
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
t
h=0
17,14 e=17
d
h=1
e=0
15
Example
h=5
e=0
a
Relabel b with h=6
Push
b
10,10
3,3
-4 along (a,b)
e(a) = 4
15,15
h=6
e=4
5,5
s
8,8
h=6
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
t
h=0
17,14 e=17
d
h=1
e=0
16
Example
h=7
e=4
a
Relabel a with h=7
Push
b
10,10
3,3
-4 along (s,a)
e(a) = 0
15,11
h=6
e=0
5,5
s
8,8
h=6
12,11
c
h=7
e=0
Preflow Push Algorithm
6,6
t
h=0
17,14 e=17
d
h=1
e=0
17
Example
h=7
e=0
15,11
a
No active nodes
left
The algorithm
terminates
h=6
e=0
b
10,6
3,3
5,5
s
8,8
h=6
12,11
c
6,6
h=7
e=0
t
h=0
17,14 e=17
d
h=1
e=0
Min-cut
Preflow Push Algorithm
18
Pseudo code
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
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);
}
}
Preflow Push Algorithm
19
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
Preflow Push Algorithm
20
Parallelism profile for Preflow Push
Input Graph: 512x512 Grid
Preflow Push Algorithm
21
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
Preflow Push Algorithm
22
Preflow Push: Global Relabeling
h=2
e=0
h=1
e=0
4
a
4
b
11
3
6
5
s
t
8
h=6
14
11
1
h=0
e=17
3
c
h=2
e=0
6
d
h=1
e=0
Preflow Push Algorithm
23
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
Preflow Push Algorithm
24
© Copyright 2026 Paperzz