minimum cuts – theory and algorithms

26
Minimum cuts – theory and algorithms Geir Dahl, CMA, University of Oslo http://folk.uio.no/geird/ Workshop, Bergen, Jan. 2008

Upload: ceobkdn

Post on 21-Apr-2017

228 views

Category:

Documents


1 download

TRANSCRIPT

Minimum cuts –

theory and algorithms

Geir Dahl, CMA, University of Oslohttp://folk.uio.no/geird/

Workshop, Bergen,Jan. 2008

Plan

I graphs, basic concepts

I flows and cuts

I the minimum st-cut problem

I the maximum flow problem

I algorithms

Graphs

I Def.: a graph is an ordered pair G = (V ,E ), where ...

I V : finite set, each element called a vertex (node, point),

I E : set of unordered pairs from V ; each such pair is called anedge or a line.

Visualize a graph: drawing (embedding) in the plane.

u

v

w

e g

Paths

I path: alternating sequence of consecutive vertices and edges;no repeated vertex

I often: viewed as a sequence of edges.

I st-path: path between vertices s and t

u

v

w

e g

p

q

I Question: how many paths are there? Assume completegraph.

Graphs

I Walk: like a path, but repeated vertices are allowed. Thelength of a walk is the number of edges.

I Adjacency matrix: Given a graph G = (V ,E ) with verticesv1, . . . , vn, its adjacency matrix A ∈ IRn×n is a (0, 1)-matrixwhere the (i , j)’th element is 1 if [vi , vj ] ∈ E and 0 otherwise.A is symmetric and that it has zeros on the diagonal.

Theorem: The (i , j)’th entry of An, the n’th power of An, equalsthe number of different vivj -walks of length n in G.

Directed graphsA directed graph (digraph) D = (V ,E ) is defined like a graph,except that edges have a direction, so each edge (u, v) is anordered pair of vertices. Sometimes (directed) edges are calledarcs.

I e = (u, v): an edge from u to v

I two types of paths in a directed graph

I Type 1: directed path: all edges have the same direction:P = ((v1, v2), (v2, v3), . . . , (vk−1, vk)).

I Type 2: a path with both backward and forward arcs

A flow concept: st-flow

Notation:

I δ+(v) = {e ∈ E : e = (v ,w) for some w}: arcs leaving v .

I δ−(v) = {e ∈ E : e = (w , v) for some w}: arcs entering v .

Given:

I D = (V ,E ) directed graph

I Two distinct vertices s, t ∈ V ; s is source and t is sink.

I a function: c : E → IR+; ce = c(u,v) is called the capacity ofedge e = (u, v).

A function x : E → IR+ is called an st-flow if the following holds∑e∈δ+(v) xe −

∑e∈δ−(v) xe = 0 for alle v ∈ V \ {s, t};

0 ≤ xe ≤ ce for all e ∈ E .

Comments:

I view this as a stationary flow

I the equations reflect the flow conservation law

I inequalities: nonnegativity + capacity

Example: an st-flow

s

t

3

4

3

2

2

5

Maximum flow

Consider:

I D = (V ,E ) directed graph, s, t ∈ V

I c : E → IR+: capacity function

I may assume no arc entering s and no leaving t

I define the value val(x) of an st-flow x as the amount of flowleaving the source s, i.e.,

val(x) =∑

e∈δ+(s)

xe .

The maximum flow problem is to find

an st-flow x with maximum value val(x).

What kind of optimization problem is this?

I continuous variables

I linear objective function val(x) = cT x

I constraints: linear equations and linear inequalities.

I So: a linear optimization problem (linear programming): LP

Lemma: A maximum st-flow x exists.

Proof: The set of feasible points is compact and the functionx → val(x) is continuous: apply the Extreme Value Theorem.

From the LP connection:

I proves existence once more

I may use efficient general LP algorithms, e.g. the simplexmethod.

I but we shall explain a combinatorial approach.

This is where the cuts come into play!

CutsLoosely speaking a cut in a graph is a set of edges which is abottleneck: you have to go through this bottleneck to get fromone side to the other.

More precisely, consider the situation:

I D = (V ,E ) directed graph, s, t ∈ V (distinct)

I let W ⊂ V where s ∈ W and t 6∈ W .

I define

K = δ+(W ) = {(w , v) ∈ E : w ∈ W , v 6∈ W }.

I and this set is called an st-cut.

I Moreover, if c : E → IR+ is a capacity function, we define thecapacity of the cut K = δ+(W ) as the total capacity of itsedges:

cap(K ) :=∑

e∈δ+(W )

ce .

I There is a finite number of cuts, so a trivial algorithm isenumeration.

I But: the number of cuts grows exponentially in n (except forsimple graphs).

I Many combinatorial problems are computationally hard forsimilar reasons.

I Some, however, have some kind of mathematical structurethat opens up for efficient algortihms.

I This is true for the minimum cut problem.

I But not for the maximum cut problem!

33

5

4

1

1

W

s

t

Lemma: If x is an st-flow and K = δ+(W ) is an st-cut, then

val(x) ≤ cap(K ).

Proof: Let f (x) be the value of the st-flow x , so f (x) := x(δ+(s)),and let S ⊂ V be such that s ∈ S , t 6∈ S and let C = δ+(S). Sumthe flow conservation equations for all vertices in W \ {s}:

val(x) =∑

e∈δ+(s) xe +∑

w∈W \{s}(∑

e∈δ+(v) xe −∑

e∈δ−(v) xe)

=∑

e∈δ+(W ) xe −∑

e∈δ−(W ) xe

≤∑

e∈δ+(W ) ce

= cap(K )

The inequality came from O ≤ x ≤ c .

The following important theorem was discovered independently in1956 by Ford and Fulkerson and by Elias, Feinstein and Shannon.

The max-flow min-cut theorem: For any directed graph with arccapacity function and distinct vertices s and t the value of amaximum st-flow equals the minimum st-cut capacity:

maxx

val(x) = minK

cap(K ).

33

5

4

1

1

W

s

t

There is a nice constructive proof of this result.Illustrate this by an example. Black numbers are capacities, red orblue flows.

0. Start with zero flow, x = O.1. Find an augmenting path.

33

5

4

1

1

s

t

3 3

3

Now, val(x) = 3.

2. Find another augmenting path.

33

5

4

1

1

s

t

3 3

311

Now, val(x) = 4.

3. Find one more augmenting path.

33

5

4

1

1

s

t

3 3

3111

1

1

The resulting flow has val(x) = 5.

33

5

41

s

t

3 3

1 12 41 1

Problem solved!

Because: val(x) = cap(δ+(W )) = 5.

W

33

5

41

s

t

3 3

1 12 411

So: this suggests that

I we solve the problem by finding iteratively a directedaugmenting st-path

I for each edge in the path the present flow is below thecapacity

I and modify the flow accordingly.

I at termination we have also found a minimum cut.

WRONG !!!!

This algorithm may get stuck in a nonoptimal solution. A moreadvanced notion of augmenting path is required.

Let x be an st-flow and consider an sv -path P in D (notnecessarily directed path). Let

I P+: forward edges in P

I P−: backward edges in P

We say that P is x-augmenting to v if

I xe < de for each e ∈ P+

I xe > 0 for each e ∈ P−.

If v = t, we call P an x-augmenting path.

Proposition An st-flow x is maximum if and only if there is nox-augmenting path.

Proof: Look at the set V (x) of vertices v such that anx-augmenting to v exists.

Using a simple labeling method we determine this important setV (x); this is the core in the algorithm.

This gives the Ford-Fulkerson labeling algorithm: it solves boththe maximum flow problem and the minimum cut problem at thesame time. It works on a residual graph.

Proof of the Max-flow Min-cut theorem: Let x be a maximum flow(we know it exists!). According to the Proposition on maximumflows, there is no x-augmenting path and the flow value val(x)equals the capacity of the cut K (x) (induced by V (x) definedabove). Then, since maxx val(x) ≤ minK cap(K ), it follows that xis a maximum st-flow and K (x) is a minimum st-cut.

Algorithms

I The labeling algorithm has complexity O(nmU) where n ifthe number of vertices, m the number of edges and U themaximum capacity.

I Empirically: performs well. (Works for rational capacities.)

I Weakness: many augmentations.

I maximum augmenting path algorithm and capacity scalingalgorithm: augment on paths with large residual capacity:O(m log U)

I preflow push algorithm: O(n2m)

I highest-label preflow push algorithm: O(n2√m): fastest

I For planar graphs the min. cut problem corresponds tosolving the shortest path problem in the dual graph: givesO(n log n) algorithm.

I read more: Ahuja et al., Network Flows: Theory, Algorithmsand Applications. Prentice-Hall, 1993.

Applications

I feasible flow problem (more general flow balance constraints)

I matrix rounding

I scheduling of computer jobs (two-processor)

I tanker scheduling

I subproblem in e.g. Traveling Salesman Problem

I image restoration and segmentation

Final comments

I max-flow min-cut theorem example of a min-max theorem,often involving combinatorial objects.

I related to the duality theory of linear optimization and thenotion of total unimodularity of matrices.