[acm-icpc] minimum cut

67
Minimum Cut 郭至軒(KuoE0[email protected] KuoE0.ch

Upload: chih-hsuan-kuo

Post on 15-May-2015

593 views

Category:

Education


5 download

TRANSCRIPT

Page 2: [ACM-ICPC] Minimum Cut

Cut

Page 3: [ACM-ICPC] Minimum Cut

cut (undirected)

Page 4: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

undirected graph

A partition of the vertices of a graph into two disjoint subsets

Page 5: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

undirected graph

A partition of the vertices of a graph into two disjoint subsets

Page 6: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

undirected graph

A partition of the vertices of a graph into two disjoint subsets

Page 7: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

A partition of the vertices of a graph into two disjoint subsets

undirected graph

Page 8: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

Cut-set of the cut is the set of edges whose end points are in different subsets.

undirected graph

Page 9: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

Cut-set of the cut is the set of edges whose end points are in different subsets.

Cut-set

undirected graph

Page 10: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

weight = number of edges or sum of weight on edges

weight is 7

undirected graph

Page 11: [ACM-ICPC] Minimum Cut

cut (directed)

Page 12: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

directed graph

A partition of the vertices of a graph into two disjoint subsets

Page 13: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

directed graph

A partition of the vertices of a graph into two disjoint subsets

Page 14: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

directed graph

A partition of the vertices of a graph into two disjoint subsets

Page 15: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

directed graph

A partition of the vertices of a graph into two disjoint subsets

Page 16: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

directed graph

Cut-set of the cut is the set of edges whose end points are in different subsets.

Page 17: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

directed graph

Cut-set of the cut is the set of edges whose end points are in different subsets.

Page 18: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

Cut-set

directed graph

Cut-set of the cut is the set of edges whose end points are in different subsets.

Page 19: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

weight is 5⇢ or 2⇠

directed graph

weight = number of edges or sum of weight on edges

Page 20: [ACM-ICPC] Minimum Cut

s-t cut1. one side is source

2. another side is sink

3. cut-set only consists of edges going from source’s side to sink’s side

Page 21: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

flow network

Source Sink Other

Page 22: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

flow network

Source Sink

Page 23: [ACM-ICPC] Minimum Cut

1

3

5

6

7

8

9

2

4

flow network

Source Sink

Page 24: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

flow network

cut-set only consists of edges going from source’s side to sink’s side

Page 25: [ACM-ICPC] Minimum Cut

1

2

85

4

7

9

3

6

weight is 6

flow network

cut-set only consists of edges going from source’s side to sink’s side

Page 26: [ACM-ICPC] Minimum Cut

Max-Flow Min-Cut Theorem

Page 27: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 3 + 3 = 6

Page 28: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 3 + 3 = 6

Page 29: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 3 + 4 - 1 = 6

Page 30: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 3 + 4 - 1 = 6

Page 31: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 4 + 2= 6

Page 32: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 4 + 2= 6

Page 33: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 4 + 2= 6

Page 34: [ACM-ICPC] Minimum Cut

Observation 1The network flow sent across any cut is equal to the amount reaching sink.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

total flow = 6, flow on cut = 4 + 2= 6

Page 35: [ACM-ICPC] Minimum Cut

Observation 2Then the value of the flow is at most the capacity of any cut.

1

3

2 4

5

6

3

8

4

2

4

4

3

It’s trivial!

Page 36: [ACM-ICPC] Minimum Cut

Observation 2Then the value of the flow is at most the capacity of any cut.

1

3

2 4

5

6

3

8

4

2

4

4

3

It’s trivial!

Page 37: [ACM-ICPC] Minimum Cut

Observation 3Let f be a flow, and let (S,T) be an s-t cut whose capacity equals the value of f.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

f is the maximum flow(S,T) is the minimum cut

Page 38: [ACM-ICPC] Minimum Cut

Observation 3Let f be a flow, and let (S,T) be an s-t cut whose capacity equals the value of f.

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

f is the maximum flow(S,T) is the minimum cut

Page 39: [ACM-ICPC] Minimum Cut

Max-Flow

EQUAL

Min-Cut

Page 40: [ACM-ICPC] Minimum Cut

Example

Page 41: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

3

8

4

2

4

4

3

Page 42: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

Maximum Flow = 6

Page 43: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Residual Network

Page 44: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Minimum Cut = 6

Page 45: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Minimum Cut = 6

Page 46: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Minimum Cut = 6

Page 47: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Minimum Cut = 6

Page 48: [ACM-ICPC] Minimum Cut

The minimum capacity limit

the maximum flow!

Page 49: [ACM-ICPC] Minimum Cut

find a s-t cut

Page 50: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

3/3

3/8

4/4

2/2

1/4

4/4

2/3

Maximum Flow = 6

Page 51: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Travel on Residual Network

Page 52: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

start from source

Page 53: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

don’t travel through full edge

Page 54: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

don’t travel through full edge

Page 55: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

no residual edge

Page 56: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

no residual edge

Page 57: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

s-t cut

Page 58: [ACM-ICPC] Minimum Cut

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

s-t cut

Page 59: [ACM-ICPC] Minimum Cut

result of starting from sink

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Page 60: [ACM-ICPC] Minimum Cut

result of starting from sink

1

3

2 4

5

6

0/3

5/8

0/4

0/2

3/4

0/4

1/3

Page 61: [ACM-ICPC] Minimum Cut

Minimum cut is non-unique!

Page 62: [ACM-ICPC] Minimum Cut

time complexity:based on max-flow algorithm

Ford-Fulkerson algorithm O(EF)

Edmonds-Karp algorithm O(VE2)

Dinic algorithm O(V2E)

Page 63: [ACM-ICPC] Minimum Cut

Stoer Wagneronly for undirected graph

time complexity: O(N3) or O(N2log2N)

Page 66: [ACM-ICPC] Minimum Cut

Reference• http://www.flickr.com/photos/dgjones/335788038/

• http://www.flickr.com/photos/njsouthall/3181945005/

• http://www.csie.ntnu.edu.tw/~u91029/Cut.html

• http://en.wikipedia.org/wiki/Cut_(graph_theory)

• http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem

• http://www.cs.princeton.edu/courses/archive/spr04/cos226/lectures/maxflow.4up.pdf

• http://www.cnblogs.com/scau20110726/archive/2012/11/27/2791523.html

Page 67: [ACM-ICPC] Minimum Cut

Thank You for Your Listening.