# What you misses!

date post

22-Jan-2016Category

## Documents

view

15download

0

Embed Size (px)

description

### Transcript of What you misses!

What you misses!Something very valuable was missing in a lab. There were 6 RAs (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 RAs who saw someone and did not tell. Can you identify a liar? Explain.

The investigationConstruct a graph indicating the time overlap relations among the RAs.The graph should be an interval graph like the one below.AFEDCB

But there is an induced cycle of length 4 (BDCF),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.

What you probably wont 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.

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

OutlineBipartite matching.Network flow.Ford and Fulkersons algorithm.Max-flow Min-cut theorem.Efficient algorithms.General MatchingApplications.

adcbe143265Matching Making Service (MaMaServ)

123456abcde

adcbe143265edcba654321Matching Making Service (MaMaServ)

f joins in at the last minuteadcbe143265Matching Making Service

f

123456abcdef

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

adcbfe143265fedcba654321Matching Making Service

General Techniques for Flow and MatchingStarting from a feasible solution.Get a better solution by finding an augmenting path.Whats the difference from a greedy method?In a greedy algorithm, a decision will not be changed by subsequent operations.

Augmenting Path in Bipartite MatchingGiven 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.

Augmenting path.

Repeatfind an augmenting path modify the matchingUntil there is no augmenting path

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

adcbfe143265is an augmenting path!a-4c-2d-3e-6f-5

b26adcbfe143265ce54adf31Using BFS-like strategy to find an augmenting pathComplexity O(Fm) F=the cardinality of matching. O(nm)

Proof of correctnessSuppose 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.

adcbfe143265Must 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

- st312233321Capacity c(e).Feasible solutionCapacity constraint : 0
A forward augmenting path is a directedPath from s to t using forward edges.

A flow is maximal if there is noForward augmenting path.

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

st1010101010.yxCannot increase the flow without decrease the flow in certain edge.

st1010101010.yxRedirection must be considered on existing flows.

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

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

+

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.

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.

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.

352213365

352213365Critical edge

1522131224223

1522131224223Critical edge

122112422232321

122112422232321Critical edge

11/12112422323221

11/12112422323221

31/1211242414121

31/1211242414121

31/12135141413

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

The worst case?s-x-y-t path.yx

10001000100010001

10001000100010001

99910001000999111

99910001000999111

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

s13445634514t12352636Min-Cut?A cut of 20

Min-Cut?A cut of 18

Max-flow min-cut theorem

(Constructive proof by Ford and Fulkerson)Any augmentation path will increase the total flow.When there is no augmentation path can be found in the residual graph, the flow equals a cut.Any flow is not greater than the min-cut.

31/12135141413A min cut!

stFinishedInitialst

Now we proved the algorithm is correct, what about the time complexity?Use a good ordering strategy to avoid repeating.

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.

STC1Ck-1C2The edges between consecutive layers are called feasible.Only feasible edges are considered to find an augmenting path.

STC1Ck-1C2Critical edge

STC1Ck-1C2

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.

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)

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

A bipartite matching problem can be solved by network flowadcbfe143265

A bipartite matching problem can be solved by network flowadcbfe143265stEach edge hascapacity 1Max flow equals maximum cardinality.

Operations within a domainInteger number is closed under addition, subtraction, and multiplication.

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

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.

The Fair Meal ProblemAlice, 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?

Alice

Bob

David

Elsa

FrankVegetables

Meats

Sea Foods

Poultry

AppetizersSweet and SourFish

Khorma

NO. 4

NO. 23...NO.37st

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 theyd better to be able to communicate by one language.How to divide all pilots into teams such that the available teams is maximum?

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!

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