0% found this document useful (0 votes)
2 views26 pages

317 Max Flow

The document discusses the Maximum-Flow Problem and the Ford-Fulkerson Algorithm, focusing on flow networks characterized by capacities on edges, source and sink nodes, and the flow itself. It explains the concepts of flow, value of flow, and the residual graph, as well as the process of finding augmenting paths to maximize flow. Additionally, it covers the relationship between maximum flow and minimum cut, highlighting the constraints imposed by the network structure.

Uploaded by

ananyasingla072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views26 pages

317 Max Flow

The document discusses the Maximum-Flow Problem and the Ford-Fulkerson Algorithm, focusing on flow networks characterized by capacities on edges, source and sink nodes, and the flow itself. It explains the concepts of flow, value of flow, and the residual graph, as well as the process of finding augmenting paths to maximize flow. Additionally, it covers the relationship between maximum flow and minimum cut, highlighting the constraints imposed by the network structure.

Uploaded by

ananyasingla072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

ULC403

Design and Analysis of Algorithms

The Maximum-Flow Problem and the


Ford-Fulkerson Algorithm

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 1 / 26
Transportation networks

■ Transportation networks: Networks whose edges carry some sort of


traffic and whose nodes act as “switches” passing traffic between dif-
ferent edges.
S.No Transport Networks Edges Nodes
1 Highway System Highways Interchanges
2 Computer Networks Links that can switches
carry packets
3 Fluid Networks Pipes that carry Junctures
liquid/fluid where pipes
are plugged
together.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 2 / 26
Graphs in modelling of Transportation Networks
■ Network models of this type have several ingredients:
• capacities on the edges, indicating how much they can carry;
• source nodes in the graph, which generate traffic;
• sink nodes in the graph, which can “absorb” traffic as it arrives
and
• the traffic/flow itself, which is transmitted across the edges.

Figure: A flow network, with source s and sink t. The numbers next to the edges
are the capacities.
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 3 / 26
Flow Networks

■ A flow network is a directed graph G = (V, E) with the following fea-


tures.
• Associated with each edge < u, v >∈ E is a capacity, which is a
nonnegative number that we denote c(u, v) ≥ 0
• There is a single source node s ∈ V
• There is a single sink node t ∈ V
■ Assumptions about the flow networks
1) No edge enters the source s and no edge leaves the sink t,
2) There is at least one edge incident to each node,
3) All capacities are integers.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 4 / 26
Defining flow

■ What it means for our n/w to carry traffic/flow:


• an abstract entity (generated at source nodes → transmitted across
edges → absorbed at sink nodes).
• An s − t flow is a function f that maps each edge < u, v >∈ E
to a nonnegative real number, f : V × V → R+ .
• f (u, v) intuitively represents the amount of flow carried by
edge < u, v >∈ E.
■ A flow f must satisfy the following two properties.
(i) (Capacity conditions) For each < u, v >∈ E, we have
0 ≤ f (u, v) ≤ c(u, v).
(ii) (Conservation conditions) For each node u ∈ V other than s
and t, we have
∑ ∑ ∑ ∑
v∈V f (u, v) = v∈V f (v, u) or e into v f (e) = e out of ∈v f (e)
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 5 / 26
Value of a flow

■ The value of a flow f , denoted v(f ), is defined to be the amount of


flow generated at the source:
∑ ∑
|f | = v(f ) = e out of s f (e) = e into t f (e)
∑ ∑
|f | = v(f ) = v∈V f (s, v) = v∈V f (v, t)

■ The flow into the sink node (t) is same as flow going out from the
source node (s) and thus, the flow is conserved.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 6 / 26
The Lucky Puck Company’s trucking problem.

Figure: A flow network G = (V, E) for LPCT.

+ The Jalandhar factory is the source s, and the Delhi warehouse is the
sink t.

+ Pucks are shipped through intermediate cities, but only c(u, v) crates
per day can go from city u to city v.

+ Each edge is labeled with its capacity.


. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 7 / 26
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 8 / 26
The Maximum-Flow Problem

■ Given a flow network G(V, E), with a capacity associated with each
edge in E and two distinguished nodes s and t known as source and
sink respectively,

■ Given a flow network G(V, E), find a flow of maximum possible


value.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 9 / 26
Designing the Algorithm

■ Always set the flow as high as the edge capacities would allow while
preserving the conservation conditions.
■ Is this the maximum possible for the graph in the figure?
• no other s − t path on which we can directly push flow without
exceeding some capacity
• yet we do not have a maximum flow. . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 10 / 26
More general way of pushing flow from s → t

■ Let’s perform the operation denoted by a dotted line.


■ Dark edges are carrying flow before the operation, and the dashed edges
form the new kind of augmentation

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 11 / 26
Systematically pushing flows: Residual graph

■ We can push forward on edges with leftover capacity, and

■ We can push backward on edges that are already carrying flow, to divert
it in a different direction.

■ The residual graph provides a systematic way to search for forward-


backward operations such as this.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 12 / 26
Residual Graph

■ Given a flow network G = (V, E) and a flow f , the residual network of


G induced by f is Gf = (V, Ef ), where

Ef = {(u, v) ∈ V × V : cf (u, v) >0} with residual capacity cf

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 13 / 26
Residual Graph Construction

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 14 / 26
Augmenting Paths in a Residual Graph

■ The way in which we push flow from s to t in Gf is as follows.


• An augmenting path p is a simple path from s to t on a residual
network Gf . Choose an augmenting path.
• Residual capacity: The maximum capacity by which we can
increase the flow on each edge in an p is known as the residual
capacity of p

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 15 / 26
Max-flow: Ford Fulkerson Algorithm

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 16 / 26
Complexity Analysis

■ A straightforward implementation of FORD-FULKERSON runs in time


O(E|f ∗ |), where f ∗ is the maximum flow found by the algorithm.
• Initialisation take time Θ(E) .
• The while loop is executed at most |f ∗ | times, since the flow value
increases by at least one unit in each iteration.
• The time to find a path in a residual network is O(E).
• The time to update capacity and flow values is O(1).

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 17 / 26
Edmonds-Karp algorithm

■ It’s similar to a Ford-Fulkerson method.

■ The algorithm is identical to the Ford–Fulkerson algorithm, except that


the search order when finding the augmenting path is defined.

■ It chooses the augmenting path as a shortest path from s to t in


the residual network.

■ Edmonds-Karp algorithm runs in O(V E 2 ) time.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 18 / 26
Max-flow and Min-cut
Are they related ?

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 19 / 26
The structure of the flow network & Max-flow

■ Note: the structure of the flow network places upper bounds on the
maximum value of an s-t flow.
■ A basic “obstacle” to the existence of large flows:
• Divide the nodes of the graph into two sets, S and T , so that
s ∈ S and t ∈ T .

• Any flow that goes from s to t must cross from S into T at some
point, and thereby use up some of the edge capacity from S to T .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 20 / 26
Cut-sets of Flow Networks
■ A cut in a network is a partition of V into S and T (T = V − S)
such that s (source) is in S and t (target) is in T .
■ Each such “cut” of the graph puts a bound on the maximum possible
flow value.
■ Capacity of a cut(S, T )

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 21 / 26
The upper bound on the flow

■ Let f be any s − t flow, and (S, T ) any s − t cut. Then v(f ) ≤ c(S, T ).

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 22 / 26
Min-cut

■ Min s − t cut (also called as a Min-Cut) is a cut of minimum capacity.


• The maximum-flow value equals the minimum capacity of
any such division, called the minimum cut.
• As a bonus, our algorithm will also compute the minimum cut.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 23 / 26
Max-flow min-cut theorem

■ If f is a flow in a flow network G = (V, E) with source s and sink t,


then the following conditions are equivalent:
1. f is a maximum flow in G.
2. The residual network Gf contains no augmenting paths.
3. |f | = c(S, T ) for some cut (S, T ) of G.
Note: If |f | = c(S, T ), then c(S, T ) is the required min-cut.

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 24 / 26
Applications

■ Application area of max-flow, min-cut is very vast.

■ Interested students may refer the document available at


MAX-FLOW-APPLICATIONS

. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 25 / 26
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
(DAA, Dr. Ashish Gupta) ULC403 : Unit-III 26 / 26

You might also like