0% found this document useful (0 votes)
7 views

M4_flow networks

Uploaded by

ananaeygarg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

M4_flow networks

Uploaded by

ananaeygarg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Flow Networks

• A flow network G =(V;E) is a directed graph in which each edge (u,v)E has a
nonnegative capacity c(u,v)≥ 0.

• if E contains an edge (u,v), then there is no edge (v, u) in the reverse direction.

• If (u,v)E, then c(u,v)=0, and no self-loops are allowed.

• distinguish two vertices in a flow network: a source s and a sink t .

• For convenience, assume that each vertex lies on some path from the source to the sink.
i.e., for each vertex v V , the flow network contains a path s  v t.

• The graph is therefore connected and, since each vertex other than s has at least one
entering edge, |E|≥ |V| - 1.
Defining Flow
• Let G =(V,E) be a flow network with a capacity function c.

• Let s be the source of the network, and let t be the sink.

• A flow in G is a real-valued function f : V X V -> R that satisfies the following two properties:

• Capacity constraint: For all u,v V , 0 ≤ f (u,v) c.u; /.

• Flow conservation: For all u  V –(s, t),

When (u,v) E, there can be no flow from u to v , and f (u,v)= 0.


Fig: Flow Network

Fig: Flow in G
Maximum flow problem
• Let f(u,v) be the flow from vertex u to vertex v, which is a non negative quantity.

• The value |f| of flow f is defined as the total flow out of the source minus the flow into the source.:

Typically, a flow network will not have any edges into the source, and the flow into the source, given
by the summation will be 0.

maximum-flow problem:
Given a flow network G with source s and sink t , and find a flow of maximum value.
The Ford-Fulkerson method

• The Ford-Fulkerson method iteratively increases the value of the flow.


• Start with f(u,v)=0 for all u,vV , giving an initial flow of value 0.
• At each iteration, increase the flow value in G by finding an “augmenting path” in an associated “residual network”
Gf .
• Once the edges of an augmenting path are known in Gf , one can easily identify specific edges in G for which one
can change the flow so that the value of the flow can be increased.
• Although each iteration of the Ford-Fulkerson method increases the value of the flow, see that the flow on any
particular edge of G may increase or decrease; decreasing the flow on some edges may be necessary in order to
enable an algorithm to send more flow from the source to the sink.
• Repeatedly augment the flow until the residual network has no more augmenting paths.
Residual networks
• Given a flow network G and a flow f , the residual network Gf consists of edges with capacities that represent how one can change the flow on
edges of G.

• An edge of the flow network can admit an amount of additional flow equal to the edge’s capacity minus the flow on that edge.

• If that value is positive, then place that edge into Gf with a “residual capacity” of cf(u,v)= c(u,v)- f(u,v).

• The only edges of G that are in Gf are those that can admit more flow; those edges (u,v) whose flow equals their capacity have cf(u,v)= 0, and they
are not in Gf .

• The residual network Gf may also contain edges that are not in G.

• As an algorithm manipulates the flow, with the goal of increasing the total flow, it might need to decrease the flow on a particular edge.

• In order to represent a possible decrease of a positive flow f (u,v) on an edge in G, we place an edge (v,u) into Gf with residual capacity cf(v,u)=
f(u,v) that is, an edge that can admit flow in the opposite direction to (u,v), at most canceling out the flow on (u,v).

• These reverse edges in the residual network allow an algorithm to send back flow it has already sent along an edge.

• Sending flow back along an edge is equivalent to decreasing the flow on the edge, which is a necessary operation in many algorithms.
• Let G=(V,E) be the flow network with source s and sink t.
• Let f be flow in G and consider a pair of vertices u,vV.
• The residual capacity cf(u,v) is defined by:

• Because of our assumption that (u,v) E implies (v,u)E, exactly one case in above equation
applies to each ordered pair of vertices.

• Given a flow network G=(V,E) and a flow f , the residual network of G induced by f is Gf =(V,E),
where
Ef = {(u,v) V x V : cf(u,v) > 0}.

• Each edge of the residual network, or residual edge, can admit a flow that is greater than 0.
Augmenting Paths
• Given a flow network G =(V,E) and a flow f , an augmenting path p is a simple
path from s to t in the residual network Gf .

• By the definition of the residual network, we may increase the flow on an edge
(u,v) of an augmenting path by up to cf(u,v) without violating the capacity
constraint on whichever of (u,v) and (v,u) is in the original flow network G.

• the maximum amount by which we can increase the flow on each edge in an
augmenting path p the residual capacity of p, given by
Minimum cut The net flow across this cut is

the capacity of this cut is

A minimum cut of a network is a cut whose capacity is minimum over all cuts of the network.
Analysis
• The running time of FORD-FULKERSON depends on how the augmenting path p in line 3 is found. If choosen it poorly, the

algorithm might not even terminate: the value of the flow will increase with successive augmentations, but it need not even

converge to the maximum flow value.

• If the augmenting path is found by using a breadth-first search, however, the algorithm runs in polynomial time.

• In practice, the maximum-flow problem often arises with integral capacities. If the capacities are rational numbers, one can

apply an appropriate scaling transformation to make them all integral.

• If f* denotes a maximum flow in the transformed network, then a straightforward implementation of FORD-FULKERSON

executes the while loop of lines 3–8 at most |f*| times, since the flow value increases by at least one unit in each iteration.

• One can perform the work done within the while loop efficiently if the flow network G=(V,E) is implemented with the right

data structure and find an augmenting path by a linear-time algorithm.


• Let us assume that one can keep a data structure corresponding to a directed graph
G’=(V,E’), where E’={(u,v): (u,v) 2 E or (v,u)E }.

• Edges in the network G are also edges in G’, and therefore one can easily maintain
capacities and flows in this data structure.

• Given a flow f on G, the edges in the residual network Gf consist of all edges (u,v) of G’
such that cf(u.v)>0

• The time to find a path in a residual network is therefore O(V+E’)= O(E) if either depth-
first search or breadth-first search is used.

• Each iteration of the while loop thus takes O(E) time, as does the initialization in lines 1–
2, making the total running time of the FORD-FULKERSON algorithm O(E |f*|).

You might also like