FIFO Push Relabel Algorithm
The push–relabel algorithm (alternatively, pre flow–push algorithm) is an algorithm for computing maximum flows in a flow network. Push-relabel algorithms work in a more localized manner than the Ford Fulkerson method. Rather than examine the entire residual network to find an augmenting path, push-relabel algorithms work on one vertex at a time, looking only at the vertex’s neighbors in the residual network.
The push relabels algorithm can be understood in terms of fluid flows. All vertex represent pipe junctions and all directed edges represent pipes having a specific capacity. Each vertex has two special properties. They contain a reservoir to store any excess flow and the vertex along with the reservoir are placed on a platform at a specific height.
We can push flow only downhill, that is, from a vertex at a greater height to one at a lower height. Initially, the source is at a height of V (number of vertices) and the sink is at a height of 0. The height of all the other vertices is 0 and increases as the algorithm progresses. First, we send as much flow as we can from the source to all of its intermediate vertices, where it is stored in their reservoir.
Now all the intermediate vertices of the source are overflowing. We can not push flow forward since they will be located at a height 0. In order to send flow forward, we must increase their height by 1.
The process continues until we reach the sink.
In the end, we empty all the excess fluid stored in any of the vertex reservoirs (if any) by sending flow back to the source. The flow obtained then will be maximum flow.
- Push: Push operation is applied on an overflowing vertex to push the flow forward. The algorithm finds adjacent vertices of u which are at a lower height than u. For each such adjacent vertex, it sends the maximum possible flow, which is the minimum of excess flow at u and capacity of the edge connecting u with v.
- Relabel: Relabel operation is applied on an overflowing vertex u to increase its height. The algorithm finds adjacent vertex v of u which has the minimum height. It then updates
*** QuickLaTeX cannot compile formula: *** Error message: Error: Nothing to show, formula is empty
The generic push-relabel algorithm uses an initialize–pre flow function. The function is presented below followed by the algorithm.
1. initialize height and excess flow of every vertex to 0
2. set height of source to number of vertices
3. initialize flow of each edge to 0
4. for each adjacent vertex of source, set its flow and excess flow to capacity of edge connecting them
2. while there exists an applicable push or relabel operation
3. select an applicable push or relabel operation and perform it
4. return flow
FIFO Push-Relabel vs Push-Relabel
FIFO push relabel is an optimization in the original push relabel. Instead of spending linear time finding the overflowing vertex, we organise all the overflowing vertices in a queue. Doing so allows us to find an overflowing vertex in constant time. This reduces the time complexity to O(V3) from O(V2E).
Implementation of FIFO Push-Relabel Algorithm
Example Problem Statement: In below code, a directed graph has been encapsulated in a class DirectedGraph which has been implemented first. It contains a nested class Vertex which encapsulates the edge of the graph. Consider the graph given below –
The edge from 0 -> 1 will be encapsulated by a vertex object V(1, 3) where 1 is the destination and 3 is the weight. It will be stored at index 0 of adjacency matrix. Here is the adjacency matrix of the above graph.
0: [[1, 3], [3, 4]] 1: [[2, 1]] 2: [[3, 2]] 3: 
Max flow: 23
Time Complexity: O(V3)
Please Login to comment...