27
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Embed Size (px)

DESCRIPTION

Flow Given a flow network G=(V,E) with capacity function c. Let s be the source and t the sink. A flow in G is a real-valued function f: V×V  R satisfying the following three properties: Capacity constraint: For all u,v  V, f(u,v)  c( u,v). Skew symmetry: For all u,v  V, f(u,v) = -f(v, u). Flow conservation: For all u  V-{s,t}, If (u, v)  E, and (v, u)  E, then we must have f (u, v) = f (v, u) = 0. By skew symmetry, for all v  V-{s,t},

Citation preview

Page 1: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Maximum Flow Problem

Definitions and notationsThe Ford-Fulkerson method

Page 2: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Flow Networks

Page 3: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

FlowGiven a flow network G=(V,E) with capacity function c. Let s be the source and t the sink.A flow in G is a real-valued function f: V×V R satisfying the following three properties:

Capacity constraint: For all u,v V, f(u,v) c( u,v). Skew symmetry: For all u,v V, f(u,v) = -f(v, u) . Flow conservation: For all u V-{s,t},

( , ) 0v V

f u v

If (u, v) E, and (v, u) E, then we must have f (u, v) = f (v, u) = 0.

( , ) 0u V

f u v

By skew symmetry, for all

v V-{s,t},

Page 4: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Value of a Flow

The value of a flow is defined as

Vv

vsff ),(

Page 5: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Maximum-flow Problem

Input: a flow network G with source s and sink t.Output: a flow of maximum value

Page 6: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Working with Flows

If X and Y are sets of vertices in a flow network, then

The flow conversation property can be expressed as for all u V-{s,t}

( , ) ( , )x X y Y

f X Y f x y

( , ) 0f u V

Page 7: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Working with Flows

( , ) ( , )f f s V f V t

Page 8: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Maximum-flow Problem

Input: a flow network G with source s and sink tOutput: a flow of maximum value

How to solve it efficiently?

Page 9: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The Ford-Fulkerson Method

Why “method” not “algorithm”?

The Ford-Fulkerson method depends on three important ideas: Residual Network, Augmenting Path, and Cut.

These ideas are essential to the important max-flow min-cut theorem, which characterizes the value of maximum flow in terms of cuts of the flow network.

Page 10: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The Ford-Fulkerson Method

FORD-FULKERSON-METHOD(G, s, t)1. initialize flow f to 02. while there exists an augmenting path p3. do augment flow f along p4. return f

Page 11: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Residual NetworksGiven a flow network and a flow, the residual network consists of edges that can admit more flow. More formally, given:

G=(V, E): a flow network with source s and sink t f: a flow in G. the residual capacity of (u,v), given by: cf (u,v) = c(u,v) - f(u,v)

Residual network: Gf = (V, Ef ), where

Ef ={(u,v) V×V: cf (u,v) > 0}

Page 12: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Residual Networks (example)

Page 13: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The relationship between a flow in a residual network and one in the original network

*

Page 14: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Augmenting pathsGiven a flow network G=(V, E) and a flow f, an augmenting path is a simple path from s to t in the residual network Gf.

Residual capacity of p : the maximum amount by which we can increase the flow along the edges of an augmenting path p, i.e.,

cf (p) = min { cf (u,v): (u,v) is on p}.

2 3 1

The residual capacity is 1.

Page 15: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Augmenting Path (example)

Page 16: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Augmenting Path

Page 17: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

CutCut (S, T): S is a subset of V, T =V-S, sS and tT.Net flow across the cut (S,T): f(S,T)Capacity of the cut (S,T): c(S,T)Minimum cut of a network:

Page 18: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Cut

Page 19: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Cut

Page 20: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Cut

Page 21: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The Basic Ford-Fulkerson Algorithm

Page 22: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The Basic Ford-Fulkerson Algorithm

Page 23: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Analysis of the algorithm

The running time of the algorithm depends on how the augmenting path is determined. If it is chosen poorly, the algorithm even dose not terminate.If the capacities are integers, the time complexity is O(E f*), where f* is the value of a maximum flow. If we use breadth-first search to find the augmenting path, we can improve the time complexity to O(VE2) (Edmonds-Karp algorithm)

Page 24: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

The Edmonds-Karp algorithm

Lemma 26.8 If the Edmonds-Karp algorithm is run on a flow network G = (V, E) with source s and sink t, then fro all vertices vV-{s,t}, the shortest-path distance f(s, v) in the residual network Gf increases monotonically with each flow augmentation.

Page 25: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

Edmonds-Karp algorithm

Theorem 26.9 If the Edmonds-Karp algorithm is run on a flow network G = (V, E) with source s and sink t, then the total number of flow augmentations performed by the algorithm is O(VE).

Page 26: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method

An example

1000

1000

1000

1000

1

s

t

b

Page 27: Maximum Flow Problem Definitions and notations The Ford-Fulkerson method