Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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.

2 The investigation Construct a graph indicating the time overlap relations among the RA ’ s. The graph should be an interval graph like the one below. A F E D C B

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

4 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.

5 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).

6 Outline Bipartite matching. Network flow. Ford and Fulkerson ’ s algorithm. Max-flow Min-cut theorem. Efficient algorithms. General Matching Applications.

7 a d c b e 1 4 3 2 6 5 123456 a b c d e Matching Making Service (MaMaServ)

8 a d c b e 1 4 3 2 6 5 e d c b a 654321 Matching Making Service (MaMaServ)

9 f joins in at the last minute a d c b e 1 4 3 2 6 5 Matching Making Service 123456 a b c d e f f

10 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

11 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

12 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

13 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

14 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

15 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

16 a d c b f e 1 4 3 2 6 5 f e d c b a 654321 Matching Making Service

17 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.

18 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.

19 Augmenting path. Repeat find an augmenting path modify the matching Until there is no augmenting path A path with odd length where both endpoints are not matched And all other vertices are matched.

20 a d c b f e 1 4 3 2 6 5 is an augmenting path! a-4 c-2 d-3 e-6 f-5

21 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)

22 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.

23 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…

24 st 3 1 2 2 3 3 3 2 1 Capacity c(e). Feasible solution Capacity constraint : 0<= f(e) <= c(e) for each e Conservation constraint: f in (v) = f out (v) for each v (except s, t) Transportation Network

25 st 3 1 2 2 3 3 3 2 1 A forward augmenting path is a directed Path from s to t using forward edges. A flow is maximal if there is no Forward augmenting path.

26 st 1/3 1/1 2 2 3 3 1/3 2 1 A backward edge is added in the reversal to the direction of the flow.

27 s t 10. yx Cannot increase the flow without decrease the flow in certain edge.

28 s t 10. yx Redirection must be considered on existing flows.

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

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

31

32 +

33 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.

34 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.

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

36 3 5 2 21 3 3 6 5

37 3 5 2 21 3 3 6 5 Critical edge

38 1 5 2 21 3 1 2 2 4 2 2 3

39 1 5 2 21 3 1 2 2 4 2 2 3

40 1 2 21 1 2 4 2 2 2 3 2 3 2 1

41 1 2 21 1 2 4 2 2 2 3 2 3 2 1

42 1 1/1 21 1 2 4 2 2 3 2 3 2 2 1

43 1 21 1 2 4 2 2 3 2 3 2 2 1

44 3 21 1 2 4 2 4 1 4 1 2 1

45 3 21 1 2 4 2 4 1 4 1 2 1

46 3 21 3 5 1 4 1 4 1 3

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

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

49 1000 1

50 1

51 999 1000 999 1 1 1

52 1000 999 1 1 1

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

54 s 13 4 4 5 6 3 4 5 14 t 123 5 2 6 3 6 Min-Cut? A cut of 20

55 s 13 4 4 5 6 3 4 5 14 t 123 5 2 6 3 6 Min-Cut? A cut of 18

56 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.

57 3 1/1 21 3 5 1 4 1 4 1 3 A min cut!

58 s t Finished Initial s t

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

60 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.

61 ST C1C1 C k-1 C2C2 The edges between consecutive layers are called “feasible”. Only feasible edges are considered to find an augmenting path.

62 ST C1C1 C k-1 C2C2 Critical edge

63 ST C1C1 C k-1 C2C2

64 Key ideas Each 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.

65 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(m 2 )

66 Complexity of Network Flow Algorithms nm 2 - Edmonds, Karp 1972 n 2 m – Dinits 1970 n 3 Karvanov 1974 n 2 m ½ - Cherkaski 1977 n 5/3 m 2/3 - Galil 1978 nmlog 2 n – Galil, Naamad 1979 Shiloach 1978 nmlogn – Sleator 1980

67 A bipartite matching problem can be solved by network flow a d c b f e 1 4 3 2 6 5

68 a d c b f e 1 4 3 2 6 5 st Each edge has capacity 1 Max flow equals maximum cardinality.

69 Operations within a domain Integer number is closed under addition, subtraction, and multiplication. Rational number is closed under “ +, -, *, / ”

70 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.

71 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?

72 Alice Bob David Elsa Frank Vegetables Meats Sea Foods Poultry Appetizers Sweet and Sour Fish Khorma NO. 4 NO. 23. NO.37 s t

73 General Matching During 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?

74 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!

75 u v

76 107 2 89 34 516 b

77 7 2 89 3 b1 b’

78 10789 b1

79 References Combinatorial Optimization – Papadimitriou and Steiglitz Network Flows – Ahuja, Magnanti, and Orlin Introduction to Combinatorial Mathematics – Liu Graph Theory with Application – Bondu and Murty Introduction to Graph Theory – West Introduction to Algorithms – Corman, Leiserson, and Rivest


Download ppt "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."

Similar presentations


Ads by Google