Term Paper
-
Upload
amaresh-kumar-yadav -
Category
Documents
-
view
18 -
download
0
description
Transcript of Term Paper
Term PaperALGORITHM ANALYSIS AND DESIGN
Topic: The Ford Fulkerson Method
Submitted to :Mr. Amarjeet Singh
Submitted By:
Ranjit singh
2Algorithm Analysis And Design
Acknowledgement:-
Many people helped to create this file and each of their
contribution has been valuable. The timely completion of this
file is mainly due to the interest and persuasion of Mr. Amarjeet
Singh. who’s not only my faculty but also good friend and
guide.
His contribution will be remembered forever. It is with
deep sense of gratitude and immense pride that we
acknowledge the valuable guidance, constructive remarks and
advice given to us by our worthy teacher.
3Algorithm Analysis And Design
Contents
Introduction to Ford–Fulkerson Method
Few figures and explanations
Algorithm
Complexity
Flow Chart
Integral example
The Edmonds–Karp algorithm
Example
Maximun Flow Problem
Solution of Maximum Flow Problem
Max Flow and Min Cut
Max Flow Min Cut Theorem
Choosing Good Augmenting Paths
Application
Conclusion
Bibliography
4Algorithm Analysis And Design
INTRODUCTION
The Ford–Fulkerson Methodis an algorithm which computes the maximum flow in a flow
network. It was published in 1956. The name "Ford–Fulkerson" is often also used for the
Edmonds–Karp algorithm, which is a specialization of Ford–Fulkerson.
The idea behind the algorithm is very simple. As long as there is a path from the source (start
node) to the sink (end node), with available capacity on all edges in the path, we send flow
along one of these paths. Then we find another path, and so on. A path with available
capacity is called an augmenting path.
Ford-Fulkerson algorithm solving the maximum-flow probem.The Ford-Fulkerson algorithm
depend on three important ideas :residual networks, augmenting paths, and cuts.These ideas
are essential to the important max-flow min-cut theorem,which characterizes the value of a
maximum flow in terms of cuts of the flow network.
The Ford-Fulkerson method is iterative. Start with f(u,v)=0 for all u,v contained in V,giving
an initial flow of value 0.At each iteration ,increase the flow value by finding an augmenting
path. Repeat this process until no augmenting path can be found.
Residual networks: Intutively,given a flow network and a flow,the residual network consists
of edges that can admit more net flow.
Few figures and explanations:
Figure 1:
Residual network graph.
5Algorithm Analysis And Design
Flow network graph after the flow
Figure 2: Situation when maxflow is found.
Residual network.
Flow network ,minimal cut is shown in real.
Algorithm
Let be a graph, and for each edge from to , let be the capacity and
be the flow. We want to find the maximum flow from the source to the sink . After
every step in the algorithm the following is maintained:
Capacity
constraints:
The flow along an
edge cannot
exceed its
6Algorithm Analysis And Design
capacity.
Skew
symmetry:
The net flow from
to must be the
opposite of the
net flow from to
.
Flow
conservation:
That is, unless
or
. The net
flow to a node is
zero, except for
the source, which
"produces" flow,
and the sink,
which
"consumes" flow.
This means that the flow through the network is a legal flow after each round in the
algorithm. We define the residual network to be the network with capacity
and no flow. Notice that it can happen that a flow from to
is allowed in the residual network, though disallowed in the original network: if
and then .
7Algorithm Analysis And Design
Algorithm Ford–Fulkerson
Inputs Graph with flow capacity , a source node , and a sink node
OutputA flow from to which is a maximum
1. for all edges
2. While there is a path from to in , such that for all edges
:
1. Find
2. For each edge
1. (Send flow along the path)
2. (The flow might be "returned"
later)
The path in step 2 can be found with for example a breadth-first search or a depth-first
searchin . If you use the former, the algorithm is called Edmonds–Karp.
When no more paths in step 2 can be found, will not be able to reach in the residual
network. If is the set of nodes reachable by in the residual network, then the total capacity
in the original network of edges from to the remainder of is on the one hand equal to the
total flow we found from to , and on the other hand serves as an upper bound for all such
flows. This proves that the flow we found is maximal.
Complexity
By adding the flow augmenting path to the flow already established in the graph, the
maximum flow will be reached when no more flow augmenting paths can be found in the
graph. However, there is no certainty that this situation will ever be reached, so the best that
8Algorithm Analysis And Design
can be guaranteed is that the answer will be correct if the algorithm terminates. In the case
that the algorithm runs forever, the flow might not even converge towards the maximum
flow. However, this situation only occurs with irrational flow values. When the capacities are
integers, the runtime of Ford-Fulkerson is bounded by (see big O notation), where
is the number of edges in the graph and is the maximum flow in the graph. This is because
each augmenting path can be found in time and increases the flow by an integer
amount which is at least .
A variation of the Ford–Fulkerson algorithm with guaranteed termination and a runtime
independent of the maximum flow value is the Edmonds–Karp algorithm, which runs in
time.
Flow Chart
9Algorithm Analysis And Design
Integral example
The following example shows the first steps of Ford–Fulkerson in a flow network with 4
nodes, source and sink . This example shows the worst-case behaviour of the algorithm.
In each step, only a flow of is sent across the network. If breadth-first-search were used
instead, only two steps would be needed.
10Algorithm Analysis And Design
Notice how flow is "pushed back" from to when finding the path .
The Edmonds–Karp algorithm
In computer science and graph theory, the Edmonds–Karp algorithm is an implementation of
the Ford–Fulkerson method for computing the maximum flow in a flow network in O(VE2)
time. It is asymptotically slower than the relabel-to-front algorithm, which runs in O(V3)
time, but it is often faster in practice for sparse graphs. The algorithm was first published by a
Soviet scientist, Yefim (Chaim) Dinic, in 1970, and independently by Jack Edmonds and
Richard Karp in 1972. Dinic's algorithm includes additional techniques that reduce the
running time to O(V2E).
Algorithm
The algorithm is identical to the Ford–Fulkerson algorithm, except that the search order when
finding the augmenting path is defined. The path found must be a shortest path that has
available capacity. This can be found by a breadth-first search, as we let edges have unit
length. The running time of O(VE2) is found by showing that each augmenting path can be
found in O(E) time, that every time at least one of the E edges becomes saturated, that the
distance from the saturated edge to the source along the augmenting path must be longer than
last time it was saturated, and that the length is at most V. Another property of this algorithm
is that the length of the shortest augmenting path increases monotonically. There is an
accessible proof in.
11Algorithm Analysis And Design
Example
Given a network of seven nodes, source A, sink G, and capacities as shown below:
In the pairs written on the edges, is the current flow, and is the capacity. The residual
capacity from to is , the total capacity, minus the flow
that is already used. If the net flow from to is negative, it contributes to the residual
capacity.
12Algorithm Analysis And Design
Notice how the length of the augmenting path found by the algorithm (in red) never
decreases. The paths found are the shortest possible. The flow found is equal to the capacity
across the minimum cut in the graph separating the source and the sink. There is only one
13Algorithm Analysis And Design
minimal cut in this graph, partitioning the nodes into the sets and
, with the capacity
Maximun Flow Problem
Definition of the max-flow problem: What is the greatest rate at which material can
be shipped from the source to the sink without violating any capacity contraints?
Max flow network: G = (V, E, s, t, u) .
(V, E) = directed graph, no parallel arcs.
Two distinguished nodes: s = source, t = sink.
u(e) = capacity of arc e.
How to Solve It
The residual network has the same vertices as the original network, and one or two edges for
each edge in the original. More specifically, if the flow along the edge x-y is less than the
capacity there is a forward edge x-y with a capacity equal to the difference between the
capacity and the flow and if the flow is positive there is a backward edge y-x with a capacity
equal to the flow on x-y Let's take the following example:
14Algorithm Analysis And Design
By considering the path X_A_C_Y, we can increase the flow by 1 - the edges X_A and A_C
have capacity of 3, as in the original network, but the edge C_Y has capacity 1, and we take
the minimum of these values to get the path capacity. Increasing the flow along this path with
1 yields the flow below:
15Algorithm Analysis And Design
The value of the current flow is now 2, and as shown in Figure 1, we could do better. So, let's
try to increase the flow. Clearly, there is no point in considering the directed paths X_A_C_Y
or X_B_D_E_Y as the edges C_Y and X_B, respectively, are filled to capacity
Let's consider the only path from X to Y here: X_A_C_B_D_E_Y. Note that this is not a path
in the directed graph, because C_B is walked in the opposite way. We'll use this path in order
to increase the total flow in the original network. We'll "push" flow on each of the edges,
except for C_B which we will use in order to "cancel" flow on B_C. The amount by which
this operation can be performed is limited by the capacities of all edges along the path (as
shown in Figure 3b). Once again we take the minimum, to conclude that this path also has
capacity 1. Updating the path in the way described here yields the flow shown in Figure 1a.
We are left with the following residual network where a path between the source and the sink
doesn't exist:
16Algorithm Analysis And Design
A cut in a flow network is simply a partition of the vertices in two sets, let's call them A and
B, in such a way that the source vertex is in A and the sink is in B. The capacity of a cut is the
sum of the capacities of the edges that go from a vertex in A to a vertex in B. The flow of the
cut is the difference of the flows that go from A to B (the sum of the flows along the edges
that have the starting point in A and the ending point in B), respectively from B to A, which
is exactly the value of the flow in the network, due to the entering flow equals leaving flow -
property, which is true for every vertex other than the source and the sink.
In fact, we have solved another problem that at first glance would appear to have nothing to
do with maximum flow in a network, ie. given a weighted directed graph, remove a
minimum-weighted set of edges in such a way that a given node is unreachable from another
given node. The result is, according to the max-flow min-cut theorem, the maximum flow in
the graph, with capacities being the weights given. We are also able to find this set of edges
in the way described above: we take every edge with the starting point marked as reachable in
the last traversal of the graph and with an unmarked ending point. This edge is a member of
the minimum cut.
17Algorithm Analysis And Design
Minimum Cut Problem
Given a connected graph G=(V,E), a capacity c:E->R+, and two nodes s and t, find a
minimum s-t cut.
Cuts
An s-t cut is a node partition (S, T) such that s S, t T.
n The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
An s-t cut is a node partition (S, T) such that s S, t T.
The capacity of an s-t cut (S, T) is:
18Algorithm Analysis And Design
Min s-t cut: find an s-t cut of minimum capacity.
An s-t cut is a node partition (S, T) such that s S, t T.
The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity
19Algorithm Analysis And Design
Max Flow and Min Cut
Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then f is a max flow and (S, T) is a
min cut.
MAX-FLOW MIN-CUT THEOREM
In any network, the value of the max flow is equal to the value of the min cut.
"Good characterization."
Proof IOU.
20Algorithm Analysis And Design
Choosing Good Augmenting Paths
Use care when selecting augmenting paths.
Some choices lead to exponential algorithms.
Clever choices lead to polynomial algorithms.
Goal: choose augmenting paths so that:
Can find augmenting paths efficiently.
Few iterations.
Edmonds-Karp (1972): choose augmenting path with
Max bottleneck capacity. (fat path)
Sufficiently large capacity. (capacity-scaling)
Fewest number of arcs. (shortest path)
Application of Ford Fulkerson Method:
1. In Transport Networks:
Ford-Fulkerson algorithm is a typical one to find the maximum flow in transport networks.While
input-queued crossbar scheduling algorithms are making their efforts to match input ports and output
ports of the switch as many as possible.So,Maximum Size Matching(MSM)and Maximum Weight
Matching(MWM),which are based on the bipartite graph matching,become the theoretical criteria of
various scheduling algorithms.In this paper,we explained how to employ Ford-Fulkerson algorithm in
solving the bipartite graph matching.We have successfully applied this algorithm to the simulation of
crossbar scheduling algorithms and obtained accurate simulation results.It can be a theoretical
foundation to do further researches on scheduling algorithms.
2. Bipartite Matching:
Bipartite matching can be formulated as a max flow problem:
• Create directed graph G' = (L È R È {s, t}, E' ).
• For all edges in E, add an directed edge to E' from the node in L to the node in R.
21Algorithm Analysis And Design
• Add an edge to E' from s to each node in L.
• Add an edge to E' from each node in R to t.
• All edges in E' have a capacity of 1.
3. Disjoint Paths Problem:
• Formulation of max flow problem: Assign unit capacity to every edge.
• Max number of edge-disjoint s-t paths equals max flow value.
• Given a directed graph G = (V, E) and two nodes s and t, find the max number of edge-
disjoint s-t paths.
-Two paths are edge-disjoint if they have no edge in common.
4. Circulations with Demands:
• The circulation with demands problem extends the maximum flow problem with multiple
sources and multiple sinks.
22Algorithm Analysis And Design
– Each source has a fixed supply of “flow”
– Each sink has a fixed demand of “flow”
• Can flow be shipped across the network from the sources such that the demand from each
sink is met?
– This is a feasibility problem, not an optimization problem.
Circulation with demands can be formulated as a max flow problem:
• Add new source s and sink t.
• For each v with dv < 0, add edge (s, v) with capacity -dv.
• For each v with dv > 0, add edge (v, t) with capacity dv.
• G has circulation if and only if the new graph has max flow of
5. Survey Design:
Survey design can be formulated as a circulation with demands and lower bounds problem:
• Create directed graph G' = (V', E').
• Add a vertex for each consumer and for each product.
• Add vertices s and t.
• If consumer i owns product j, add an edge from vertex i to j with ℓe = 0 and ce = 1.
• Add an edge from s to all consumer vertices with ℓe = qi and ce = qi'.
• Add an edge from all product vertices to t with ℓe = pi and ce = pi'.
• Add an edge from t to s with ℓe = 0 and ce = ∞.
• All vertices v have demand dv = 0.
If an edge from consumer i to product j has flow of 1, consumer i is asked a question
about product j.
23Algorithm Analysis And Design
CONCLUSION AND FUTURE SCOPE :
The basic classical techniques used in maximum-flow algorithms can be adapted to solve
other network-flow problems. By solving maximum flow problem we can consider a class of
similar problems that seek to maximize the flow through a flow network while at the same
time minimizing the cost of that flow. So it can be concluded that computing the Maximum
Flow in the flow network graph produces a maximal matching set for the original Bipartite
Matching problem. And on further reflections, it can be used to solve the more powerful
Minimal Cost Flow problem, which enables us to immediately solve the Transshipment,
Transportation, and Assignment problems.
The modified Edmonds-Karp algorithm returns a maximum flow and this algorithm takes less
no. of iterations and less augmentation to calculate the maximum flow. An augmenting path
of desired capacity in each iteration can be found in O (E) time, if such a path exists. The new
modified algorithm runs in O(E2 log2C) while Edmonds-Karp algorithm runs in O (E2V).
So, finally it can be concluded that the modified Edmonds-Karp algorithm performs better in
most cases compared to Edmonds-Karp algorithm. The Ford Fulkerson algorithm is the
general algorithm to solve the network flow problems and its improvement is Edmonds-Karp
algorithm which performs better than it. So, In future more optimized algorithms can be
developed to solve the network flow problems in more efficient manner.
-----------------------------------------XXXXX--------------------------------------------
24Algorithm Analysis And Design
Bibliography
Text Book: T.H. Cormen, C.E. Leiserson, R.L. Rivest and C. Stein, Introduction to
Algorithms, PHI Pvt. Ltd., 2007
Other Specific Book: A.V.Aho, J.E. Hopcroft and J.D.Ullman, The Design and
Analysis Of Computer Algorithms, Pearson Education Asia, 2007..
http://www.cs.bgu.ac.il/~visproj/kalich/ford.htm
http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm
http://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm
http://aduni.org/courses/algorithms/courseware/handouts/Reciation_09.html
http://www-b2.is.tokushima-u.ac.jp/~ikeda/suuri/maxflow/Maxflow.shtml
http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=maxFlow