Top Banner
What you misses! Something very valuable was missing in a lab. There were 6 RA’s (A, B, C, D, E, F) work ing in the lab that night. If two persons are in the lab at the same time, at least one will see the other. No one can reenter the lab (every RA stays for a consecutive period of time). Upon investigation, each of them claims: A saw B,D. B saw A. C saw F. D saw A, B, C. E saw B, F. F saw B. Suppose there is only one liar among the RA’s who saw someone an d did not tell. Can you identify a liar? E xplain.
79

What you misses!

Jan 22, 2016

Download

Documents

matana

What you misses!. Something very valuable was missing in a lab. There were 6 RA ’ s (A, B, C, D, E, F) working in the lab that night. If two persons are in the lab at the same time, at least one will see the other . No one can reenter the lab (every RA stays for a consecutive period of time). - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: What you misses!

What you misses!Something very valuable was missing in a lab. There

were 6 RA’s (A, B, C, D, E, F) working in the lab that night. If two persons are in the lab at the same time, at least one will see the other. No one can reenter the lab (every RA stays for a consecutive period of time).

Upon investigation, each of them claims: A saw B,D. B saw A. C saw F. D saw A, B, C. E saw B, F. F saw B. Suppose there is only one liar among the RA’s who saw someone and did not tell. Can you identify a liar? Explain.

Page 2: What you misses!

The investigationConstruct a graph indicating the time overlap relations among the RA’s.The graph should be an interval graph like the one below.

A

FE

DC

B

Page 3: What you misses!

But there is an induced cycle of length 4 (BDCF),

E

F B

C D

A

Either B or C lied!This is not an interval graph!

A saw B,D. B saw A. C saw F. D saw A, B, C. E saw B, F. F saw B.

Page 4: What you misses!

What you probably won’t miss! (In the exam?)

Which of the following is a DFS (BFS) sequence of Fig. 1?Find an augmenting path in Fig.2.Is the interval graph based on the model shown in Fig.3 Eulerian?What can we say about the time complexity for recognizing interval graphs when we know that there is a O(nm) time for recognizing a circular-arc graph. (Interval graph is a subset of circular-arc graph.)Find a min-cut on a network.None of these above.

Page 5: What you misses!

Network flow and Matching

The problems that are hard but can be solved by poly-time algorithms.Rich applications.The area where graph algorithms meet linear programming (operating research).

Page 6: What you misses!

OutlineBipartite matching.Network flow.

Ford and Fulkerson’s algorithm.Max-flow Min-cut theorem.Efficient algorithms.

General MatchingApplications.

Page 7: What you misses!

a

d

c

b

e

1

4

3

2

6

5

1 2 3 4 5 6

a b c d e

Matching Making Service (MaMaServ)

Page 8: What you misses!

a

d

c

b

e

1

4

3

2

6

5 e

d

c

b

a

654321

Matching Making Service (MaMaServ)

Page 9: What you misses!

f joins in at the last minute

a

d

c

b

e

1

4

3

2

6

5

Matching Making Service

1 2 3 4 5 6

a b c d e f f

Page 10: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 11: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 12: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 13: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 14: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 15: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 16: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

f

e

d

c

b

a

654321

Matching Making Service

Page 17: What you misses!

General Techniques for Flow and Matching

Starting from a feasible solution.Get a better solution by finding an augmenting path.What’s the difference from a greedy method?

In a greedy algorithm, a decision will not be changed by subsequent operations.

Page 18: What you misses!

Augmenting Path in Bipartite Matching

Given a (partial) matching M in a graph G, an augmenting path is a path with even number of vertices (odd number of edges) such that the two end point are unmatched vertices and the edges in the path are composed by unmatched and matched edges alternatively.

Page 19: What you misses!

Augmenting path.

Repeatfind an augmenting path modify the matching

Until there is no augmenting path

A path with odd length where both endpoints are not matchedAnd all other vertices are matched.

Page 20: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

is an augmenting path!

a-4c-2d-3e-6f-5

Page 21: What you misses!

b

2

6

a

d

c

b

f

e

1

4

3

2

6

5

c

e

5

4 a

d

f

3

1

Using BFS-like strategy to find an augmenting path

Complexity O(Fm) F=the cardinality of matching. O(nm)

Page 22: What you misses!

Proof of correctness

Suppose we cannot find any augmentation path in a bipartite graph and the cardinality is not maximum. Denote the maximum matching by red edges and our partial result by blue edges.Consider all possible relations of the two sets of edges.

Page 23: What you misses!

a

d

c

b

f

e

1

4

3

2

6

5

Must have a augmenting path!

Compare each red edge with blue matching.

Pick a red edge, if it was a blue edge, ignore.

If it does not contain a matched edge, it is an augmenting path!

Otherwise, traverse alone the matched edge…

Page 24: What you misses!

s t

3

1

22

3 3

3

2

1Capacity c(e).Feasible solution

Capacity constraint : 0<= f(e) <= c(e) for each eConservation constraint: fin(v) = fout(v) for each v

(except s, t)

Transportation Network

Page 25: What you misses!

s t

3

1

22

3 3

3

2

1

A forward augmenting path is a directedPath from s to t using forward edges.

A flow is maximal if there is noForward augmenting path.

Page 26: What you misses!

s t

1/3

1/1

22

3 3

1/3

2

1

A backward edge is added in the reversal to the direction of the flow.

Page 27: What you misses!

s

t

10 10

10 10

10

.

yx

Cannot increase the flow without decrease the flow in certain edge.

Page 28: What you misses!

s

t

10 10

10 10

10

.

yx

Redirection must be considered on existing flows.

Page 29: What you misses!

What do we mean by including a backward edge in an augmenting path?

Page 30: What you misses!

The flow can be increased by reverting some previously allocated flow on a back edge.

Page 31: What you misses!
Page 32: What you misses!

+

Page 33: What you misses!

Augmenting path: Forward and backward edges.

The gain by adding an augmenting path is the minimum of the remaining capacity of a forward edge or the flow of a backward edge.

Update: increase the gain on the forward edges and subtract the gain from the existing flow of the backward edges.

Page 34: What you misses!

Ford and Fulkerson

Find an augmenting path.Update the flow and data structure.Until no augmenting path can be found.

Correctness: max-flow min-cut theorem.

Page 35: What you misses!

Residual GraphThe graph that we consider in the flow algorithm.Consists both forward and backward edges (NO DIFFERENCE).Updated when each augmenting path is selected.

Page 36: What you misses!

3

5

22 1

33

6

5

Page 37: What you misses!

3

5

22 1

33

6

5

Critical edge

Page 38: What you misses!

1

5

22 1

3

1

2

2

4

2

2

3

Page 39: What you misses!

1

5

22 1

3

1

2

2

4

2

2

3

Critical edge

Page 40: What you misses!

1

22 1

1

2

4

2

2

2

3

2

3

2

1

Page 41: What you misses!

1

22 1

1

2

4

2

2

2

3

2

3

2

1

Critical edge

Page 42: What you misses!

1

1/12 1

1

2

4

2

2

3

2

3

2

2

1

Page 43: What you misses!

1

1/12 1

1

2

4

2

2

3

2

3

2

2

1

Page 44: What you misses!

3

1/12 1

1

2

4

2

4

1

4

1

2

1

Page 45: What you misses!

3

1/12 1

1

2

4

2

4

1

4

1

2

1

Page 46: What you misses!

3

1/12 1

3

5

1

4

1

4

1

3

Page 47: What you misses!

The Ford-Fulkerson algorithm might not terminate(if the initial values are not rational).First poly-time algorithm is given by Edmonds and Karp.

Page 48: What you misses!

The worst case?s

t

1000 1000

1000 1000

1

s-x-y-t path.

yx

Page 49: What you misses!

1000 1000

1000 1000

1

Page 50: What you misses!

1000 1000

1000 1000

1

Page 51: What you misses!

9991000

1000

999

1

1

1

Page 52: What you misses!

9991000

1000

999

1

1

1

Page 53: What you misses!

999999

999 999

1

1

1

1

1

Time complexity is O(Um) where U is the max-flow.NOT polynomial!

Page 54: What you misses!

s

13

4

45

6

3

4

5

14

t123

5 26

3 6

Min-Cut?

A cut of 20

Page 55: What you misses!

s

13

4

45

6

3

4

5

14

t123

5 26

3 6

Min-Cut?

A cut of 18

Page 56: What you misses!

Max-flow min-cut theorem

(Constructive proof by Ford and Fulkerson)

(1) Any augmentation path will increase the total flow.

(2) When there is no augmentation path can be found in the residual graph, the flow equals a cut.

(3) Any flow is not greater than the min-cut.

Page 57: What you misses!

3

1/12 1

3

5

1

4

1

4

1

3

A min cut!

Page 58: What you misses!

s t

FinishedInitial

s t

Page 59: What you misses!

Now we proved the algorithm is correct, what about the time complexity?

Use a good ordering strategy to avoid repeating.

Page 60: What you misses!

Choose an augmenting path with shortest length (number

of edges)Perform a BFS on a residual graph

starting form s. Partition all vertices by their shortest

distance to s.The result is called a “k-level graph”

if the distance between s and t is k.

Page 61: What you misses!

S T

C1 Ck-1C2

The edges between consecutive layers are called “feasible”.Only feasible edges are considered to find an augmenting path.

Page 62: What you misses!

S T

C1 Ck-1C2

Critical edge

Page 63: What you misses!

S T

C1 Ck-1C2

Page 64: What you misses!

Key ideasEach augmenting path identifies at least one “critical edge”.If we update the k-level graph by an augmentation path, the critical edge will be eliminated from feasible edge set.No new feasible edge will be generated by the process.

Page 65: What you misses!

After a k-level graph runs out of augmenting path, the next graph generated will have k-1 levels or less.Each has only one chance to become critical. BFS search for an augmenting path takes O(m) time.Time complexity is thus O(m2)

Page 66: What you misses!

Complexity of Network Flow Algorithms

nm2 - Edmonds, Karp 1972n2m – Dinits 1970n3 Karvanov 1974n2m½ - Cherkaski 1977n5/3 m2/3 - Galil 1978nmlog2n – Galil, Naamad 1979 Shiloach 1978nmlogn – Sleator 1980

Page 67: What you misses!

A bipartite matching problem can be solved by network flow

a

d

c

b

f

e

1

4

3

2

6

5

Page 68: What you misses!

A bipartite matching problem can be solved by network flow

a

d

c

b

f

e

1

4

3

2

6

5s t

Each edge hascapacity 1

Max flow equals maximum cardinality.

Page 69: What you misses!

Operations within a domain

Integer number is closed under addition, subtraction, and multiplication.

Rational number is closed under “ +, -, *, / ”

Page 70: What you misses!

Integral flow: the result will be in integral.

By Ford and Fulkerson. Since at each step, the change of the values are always integral.

Bipartite cardinality -> Integral flow.

Page 71: What you misses!

The Fair Meal Problem

Alice, Bob, David, Elsa, and Frank are having a food fight in an restaurant. They want to make orders with a diverse combination of different food types. Everybody insists there must be at least one dish to please him/her.

Can you help them to stop the foolish arguments?

Page 72: What you misses!

Alice

Bob

David

Elsa

Frank

Vegetables

Meats

Sea Foods

Poultry

Appetizers

Sweet and SourFish

Khorma

NO. 4

NO. 23...

NO.37

s t

Page 73: What you misses!

General MatchingDuring the WWII, the union air force have a problem. They had an assembly of pilots who speak different languages (French, English, Spanish,…). Each mission requires two crew members and they’d better to be able to communicate by one language.How to divide all pilots into teams such that the available teams is maximum?

Page 74: What you misses!

Matching on general graph (in this case, the intersection graph of the language set of each pilot.)Solving matching on general graph is more complicated since there are “flowers”.The complexities have very little difference!

Page 75: What you misses!

u

v

Page 76: What you misses!

10 7

2

89

3 4

51 6

b

Page 77: What you misses!

10 7

2

89

3

b1

b’

Page 78: What you misses!

10 789

b1

Page 79: What you misses!

ReferencesCombinatorial Optimization – Papadimitriou and SteiglitzNetwork Flows – Ahuja, Magnanti, and OrlinIntroduction to Combinatorial Mathematics – LiuGraph Theory with Application – Bondu and MurtyIntroduction to Graph Theory – WestIntroduction to Algorithms – Corman, Leiserson, and Rivest