Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matching and Factors Matchings and Covers. Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M.

Similar presentations


Presentation on theme: "Matching and Factors Matchings and Covers. Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M."— Presentation transcript:

1 Matching and Factors Matchings and Covers

2 Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M

3 Definitions: The vertices incident to the edges of a matching M are saturated by M; the others are unsaturated ( we say M- saturated and M-unsaturated). A perfect matching in a graph is a matching that saturates every vertex. G M

4 Maximum & Maximal matchings A maximal matching in a graph is a matching that cannot be enlarged by adding an edge. A maximum matching is a matching of maximum size among all matchings in the graph. Maximal ≠ maximum

5 M-alternating path Given a matching M, a M-alternating path is a path that alternates between edges in M and edges not in M M !M M

6 M-augmenting path M-augmenting paths can be used to enlarge matchings. M !M M An M-alternating path whose endpoints are unsaturated by M.

7 Theorem 3.1.10 A matching M in a graph G is a maximum matching in G if and only if G has no M-augmenting path. Only if: Trivial.

8 Symmetric difference If G and H are graphs with vertex set V, then symmetric difference GΔH is the graph with vertex set V whose edges are all those edges appearing in exactly one of G and H. We also use this notation for sets of edges; If M and M ’ are matchings, then MΔM ’ = (M-M ’ ) ∪ (M ’ -M)

9 G M M’ M Δ M’ Symmetric difference M Δ M’

10 Lemma 3.1.9 Every component of the symmetric difference of two matchings is a path or an even cycle Proof: Let F = M Δ M ’ 1. Every vertix has at most one incident edge from M and M ’ ( d(v) <=2 ) Because M and M ’ are matchings 2. ∵ Δ( F ) <=2 , every component of f is a path or a cycle.

11 Lemma 3.1.9 proof (cont’d) 3. Every path or cycle in F alternates between edges of M and edges of M ’ ∴ Every cycle has even length, with an equal number of edges from M and M ’. G M M’ M Δ M’

12 Proof of Theorem 3.1.10 If part: A matching M in a graph G is a maximum matching in G if G has no M- augmenting path. Contrapositive: G has a matching larger than M => G has an M-augmenting path. Proof: Let M ’ be a matching in G larger than M; we construct an M-augmenting path.

13 Proof of Theorem (cont’d) Let F = M Δ M ’ By Lemma 3.1.9 F consists of paths and even cycles. ( And they are M - M ’ alternating) Since |M ’ | > |M|F must have a component with more edges of M ’ than of M Cycles: Edges from M and M ’ are of equal numbers. Paths: Only start and ends with edges of M ’ That is an M-augmenting path in G.

14 Hall’s Matching Condition Seek a matching that saturates X X Y Jobs Applicants X, Y- bigraph and jobs filling problem

15 Hall’s Theorem An X, Y-bigraph G has a matching that saturates X if and only if | N(S)| ≧ |S| for all S  X Proof: –Necessity:The |S| vertices matched to S must lie in N(S) –Sufficiency: Contrapositive: If M is a maximum matching in G and M does not saturate X, then we can find a set S  X such that |N(S)| < |S|. (Notice that if maximum matching M doesn ’ t saturate X, implies X cannot be saturated anyway)

16 Proof of Hall’s Theorem (Sufficiency) Let u  X be a vertex unsaturated by M. u …..M-alternating paths ….. reachable: S and T ( u  S) X Y u S T

17 M matches T with S – {u}. 1. S – {u} is reached by an edge in M from a vertex in T. 2. T is all saturated. Because no M-augmenting path. ( M maximum) 3. 1.&2. Bijection from T to S - {u} ∴ |T| = |S - {u}| X Y u S T

18 T = N(S) 1. T  N(S) ( T are matched with S-{u}) 2. No vertex in N(S) other than T ∴ T = N(S) Suppose y  Y – T has a neighbor v  S. vy not in M: Because u is unsaturated and all the rest of S is matched to T by M. thus adding vy to an M-alt. path to v yields an M-alt. path to y => contradiction y not reachable X Y u S T = N(S) y (doesn’t exist) v

19 Completes the proof T = N(S) ∴ |N(S)| = |T| = |S| -1 < |S| For a X,Y- bigraph which X cannot be saturated, we have found a subset S of X, such that |N(S)| < |S|. We always can find it.

20 Corollary 3.1.13 For k >0, every k-regular bipartite graph has a perfect matching. Proof: 1. Counting edges by endpoints in X and in Y. k|X| = k|Y| ∴ |X|=|Y|. Perfect problem -> Hall ’ s condition. (Because saturating X also saturates Y) 2. For all S  X, let m : number of edges from S to N(S). From S: m = k|S|. From N(S): m  k|N(S)|. ∴ k|S|  k|N(S)|. Hall ’ s condition satisfied.

21 Vertex cover Definition:A vertex cover of a graph G is a set Q  V(G) that contains at least one endpoint of every edge. Q covers E(G). Policemen watch(cover); Minimum cover. G No vertex can cover more than one edge of a matching. Min Vertex Cover of G  Maximum Matching of G

22 Vertex cover Min Vertex Cover of G  Maximum Matching of G Existence of “ equality = “ PROVES both min and max. Exist?? G

23 Theorem 3.1.16 If G is a bipartite graph, then the maximum size of a matching in G equals the minimum size of a vertex cover of G. Proof: Let Q be a vertex cover, M be a matching in G. |Q|  |M|. Given a smallest Q, we construct a matching of size |Q|

24 Proof R = Q∩X , T = Q∩Y. H: the subgraph of G induced by R ∪ (Y-T); H ’ the subgraph induced by T ∪ (X- R). X Y H H’ T R S

25 Use Hall ’ s theorem to show H has a matching that saturates R into Y-T, and H ’ has a matching that saturates T. Since H and H ’ are disjoint, the two matchings form a matching of size |Q| in G. Since R ∪ T is a vertex cover, G has no edge from Y- T to X – R. For each S  R, N H (S) is contained in Y-T. If |N H (S) | < |S| then we can substitute N H (S) for S!!! And form a vertex cover smaller than Q. But Q is minimum. So R is saturated in H. Similarly T is saturated in H ’. T N H (S)

26 Min-max relation A maximization problem M and a minimization problem N defined on the same instances. Dual pair: if for every solution m in M and for every solution n in N, m  n then “ = “ proves both.

27 Independent Sets and Covers The Independence number of a graph is the maximum size of an independent set of vertices. (Independent set: within which any pair of vertices is not adjacent) No edge contains two vertices of an independent set. (compares: No vertex covers two edges of a matching)

28 Edge cover Definition: And edge cover of G is a set L of edges such that every vertex of G is incident to some edge of L. Vertices of G are covered by the edges of L. Only G ’ s without isolated vertices. G

29 Dual problems. Notation: Maximum size of independent set α(G) Maximum size of matching α ’ (G) Minimum size of vertex cover β(G) Minimum size of edge cover β ’ (G) We already have: In bipartite G, α ’ (G) = β(G). β ’ (G)  α(G)

30 Lemma 3.1.21 In a graph G, S  V(G) is an independent set if and only if S-bar is a vertex cover, and hence α(G) + β(G) = n(G). Proof: 1. Only if: since S is an independent set, then every edge is incident to at least one vertex of S-bar. i.e. S-bar is a vertex cover. ( S to S, S to S-bar, S-bar to S-bar) 2. If: S-bar covers all edges, then there are no edges joining vertices of S (S-bar ’ s bar)

31 Theorem 3.1.22 If G is a graph without isolated vertices, then α ’ (G) + β ’ (G) = n(G). Construction both sides: From a maximum matching M …. An edge cover of size n(G) - |M|. ∴ β ’ (G)  n(G) – |M| (α ’ (G)). From a minimum edge cover L …..A matching of size n(G) - |L|, ∴ α ’ (G)  n(G) – |L| (β ’ (G))

32 F rom a maximum matching M …. An edge cover of size n(G) - |M| 1. Adding to M one edge incident to each unsaturated vertex. (We can always find such edge incident to M) This is an edge cover. 2. Green use 1 vertex, blue use 2 ∴ the size of this edge cover = n(G) - |M| G M

33 F rom a minimum edge cover L …. A matching of size n(G) - |L| 1. Every component of L has at most one vertex v such that d(v) > 1, and is a star. v d(v) > 1 In L: Shouldn’t be in L. Otherwise green one can be omitted

34 F rom a minimum edge cover L …. A matching of size n(G) - |L| (cont’d) 2. Let L has k components ( k stars). Summing all edges of these stars: |L| = n(G) – k. 3.Choosing one edge from each star in L, we form a matching M of size k = n(G) - |L| L: k stars M: size k

35 Corollary By two constructions: β ’ (G)  n(G) – α ’ (G) α ’ (G)  n(G) – β ’ (G) ∴ α ’ (G) + β ’ (G) = n(G). Corollary: If G is a bipartite graph with no isolated vertices, then α(G) = β ’ (G) By Lemma 3.1.21 and Theorem 3.1.22 α(G)+β(G)= α ’ (G) + β ’ (G)

36 Algorithms and Applications Maximum bipartite matching Search for augmenting paths. If non, we find a vertex cover with the same size as the matching, thereby prove it to be maximum.

37 APA Algorithm Input: An X, Y-bigraph G, a matching M in G, and the set U of M-unsaturated vertices in X. Idea: From U ---  (M alt. Paths) ---  Reachable: S  X and T  Y. Try to extend path. Mark vertices of S that has been tried.

38 APA Algorithm Initialization: S = U and T =  Iteration: –If S has no unmarked vertex, terminate and report T ∪ (X-S) as a minimum cover and M as a maximum matching –Else: select an unmarked x  S. consider each y  N(x) such that xy  M y unsaturated: terminate and report an M- augmenting path from U to y. y saturated: y is matched to some w  X by M. include y in T( reach from x), include w in S(reach from y). after all y done, mark x, iterate.

39 APA Algorithm X Y U S T x y wx y w y w X-S

40 Correctness of APA Theorem: Repeatedly applying the APA to a bipartite graph produces a matching and a vertex cover of equal size. Equivalent: Prove that APA either produces an M-augmenting path or a vertex cover of size |M|.

41 Correctness of APA APA terminate on 2 cases. 1. Report an M-augmenting path. Finished. 2. Marking all vertices in S and report R = T ∪ (X-S) to be a vertex cover of size |M|. We must prove R.

42 R is a vertex cover and size =|M| Show there is no edge joining S to Y-T SX-S T Y-T e e is not in M:U (no M) and S-U(only via M to T) e is not in non-M: If yes, Y-T reachable.

43 R is a vertex cover and size =|M| Size of R: 1. The algorithm puts only saturated vertices in T ∴ each vertex in T is matched via M to S. 2. Since U  S, every vertex of X-S is saturated; and each vertex in X-S is matched to Y-T via M. (because all T to S) 3. |M| >= |T| + |X-S|. But no M can be bigger than this. | T | | X-S | S Y-T

44 Time complexity of APA Let G be an X, Y- bigraph with n vertices and m edges. Since α ’ (G) <= n, applying APA in O(n) times. Each APA explores X at most once before marking it. Each vertex x we look each N(x) once, so each edge in G is looked at most once …….. O(m) Overall: O(mn)

45 Matching and Factors Algorithm

46 U X Y APA Algorithm: Iteration 1 end S:U T:  Unsaturated: report an M-aug. path

47 U X Y APA Algorithm: Iteration 2 S:U T:  Saturated  put up arrows Adjust S & T

48 U X Y APA Algorithm: Iteration 2 end S:(From U via M-alt.path reachable) T: Unsaturated  report an M-aug. path

49 U X Y APA Algorithm: Iteration 3 S:= U T:=  Saturated  put up arrows Adjust S & T

50 U X Y APA Algorithm: Iteration 3 S:  U T: Saturated  put up arrows Adjust S & T

51 U X Y APA Algorithm: Iteration 3 S: T: Saturated  put up arrows Adjust S & T

52 U X Y APA Algorithm: Iteration 3 end S: T: Unsaturated: report an M-aug. path ( This time the arrows are useful )

53 U X Y APA Algorithm: Iteration 4 S: T:

54 U X Y APA Algorithm: Last Iteration S: T: Saturated  put up arrows Adjust S & T

55 U X Y APA Algorithm: Last Iteration S: T: Saturated  put up arrows Adjust S & T

56 U X Y APA Algorithm: Last Iteration S: T: Saturated  put up arrows Adjust S & T

57 U X Y APA Algorithm: Last Iteration S: T: Saturated  put up arrows Adjust S & T

58 U X Y APA Algorithm: Last Iteration S: T: Saturated  put up arrows Adjust S & T

59 U X Y APA Algorithm: Last Iteration S: T: All vertices in S are exhausted; Terminate and report a vertex cover

60 X-S X Y APA Algorithm: Last Iteration end S: T: T ∪ (X-S) is a vertex cover M is a maximum matching of the same size

61 Correctness of APA T Y-T e e is not in M:U (no M) and S-U(only via M to T) e is not in non-M: If yes, Y-T reachable. SX-S Vertex cover: because there is no edge joining S to Y-T

62 | T ∪ (X-S) | = | M | 1. T are all matched 2. X-S are all matched, too. 3. |M| >= |T| + |X-S|. But no M can be bigger than this. | T | | X-S | S Y-T

63 0 0 Weighted Bipartite Matching Matching generalized by giving weights on edges; Seek for maximum weighted matching Fill up to Kn,n with 0 X Y 5 4 7 10 2 8

64 Weighted Matching & Cover Dual: farmer and government. Weights = profit; Cover = compensation u i + v j  w i,j X Y 5 4 7 10 2 8 Farms Processing Plants u1=4 u2=3 v1=1 6 5 3 v2=4 3 510 1

65 Weighted Matching & Cover Farmer: maximize Σ w i,j Government: minimize Σ ( u i + v j ) Cost(u, v) v j  w(M) They are dual; Equality holds if M is consist of only u i +v j = w ij X Y 5 4 7 10 2 8 Farms Processing Plants u1=4 u2=3 v1=1 6 4 3 v2=4 3 510 1

66 Matrix representation: 12043 641623 750376 823458 634634 846586 X: n farms Y: n plants

67 Hungarian Algorithm Adjust the cover;until we find a cover C(u,v) = w(M) Better viewed in Matrix

68 Hungarian Algorithm 00000 641623 750376 823458 634634 846586 Excess : government over paying. 4 0

69 Hungarian Algorithm 00000 625043 727401 865430 632032 842302 Excess matrix.

70 Hungarian Algorithm ????? ?41603 ?00376 ?23450 ?34034 ?40586 Target: all excess 0, both optimum.

71 Hungarian Algorithm 00000 625043 727401 865430 632032 842302 Equality subgraph S Maximum matching of S Vertex cover of S T R T

72 Hungarian Algorithm 00000 625043 727401 865430 632032 842302 Equality subgraph S Maximum matching of S Vertex cover of S T R T ε : minimum excess ε= 1 -ε

73 Hungarian Algorithm 00000 51432 6163 0 865430 521 21 7312 1 Equality subgraph S Maximum matching of S Vertex cover of S T R T ε : minimum excess ε= 1 -ε +ε +1

74 Hungarian Algorithm 00110 514042 616400 865540 521031 731301 Equality subgraph S Maximum matching of S Vertex cover of S T R T ε : minimum excess ε= 1 -ε +ε One more 0: Equality subgraph BIGGER Only R and T get +ε, but R and T are saturated More and More 0 for unsaturated vertex

75 Hungarian Algorithm 00110 514042 616400 865540 521031 731301 Equality subgraph S Maximum matching of S Vertex cover of S TTT Next Iteration: ε = 1

76 Hungarian Algorithm 00221 403042 505400 754540 410031 620301 Equality subgraph S Maximum matching of S Vertex cover of S Result: Matching and Cover

77 Remark Non-weighted maximum matching & vertex cover problem is a special (1,0) problem.

78 Stable matching a,b,c,d ….. matching with x,y,z,w ….. with preference (for example: a: z >x >y>w) Unstable matching: a prefer x, x prefer a, but (a,x) unmatched  (a,x) unstable ab yx For a: x > y For x: a > b

79 Stable matching Stable matching: a perfect matching without unstable pair. Proposal Algorithm ( greedy) xyzwxyzw abcdabcd x: a b c d y: a c b d z: c d a b w: c b a d a: z x y w b: y w x z c: w x y z d: x y z w

80 Stable matching xyzwxyzw abcdabcd x: a b c d y: a c b d z: c d a b w: c b a d a: z x y w b: y w x z c: w x y z d: x y z w Step 1: Two proposer, refuse the less like one

81 Stable matching xyzwxyzw abcdabcd x: a b c d y: a c b d z: c d a b w: c b a d a: z x y w b: y w x z c: w x y z d: x y z w Step 2: Two propose r, refuse the less like one Observation: X moves right and O moves left.

82 Stable matching xyzwxyzw abcdabcd x: a b c d y: a c b d z: c d a b w: c b a d a: z x y w b: y w x z c: w x y z d: x y z w Step 3: Every woman gets only one proposal. Agree and stop.

83 Stable matching Proof of correctness: There doesn ’ t exist some (a,x) unstable. Men (the ones who propose) are happier.

84 Matching and Factors Factors

85 Definition Fatctor: spanning subgraph in G K- factor: spanning k – regular subgraph 3 factor

86 Definition 1 – Fatctor A 1 – factor is a perfect match with its vertices. 1 factorPerfect match

87 Tutte’s condition  s  V(G), o(G-s)  |s| Tutte ’ s theorem: A graph G has a 1- factor, if and only if T.C. holds. S

88 Tutte’s condition  s  V(G), o(G-s)  |s| Tutte ’ s theorem: A graph G has a 1-factor, if and only if T.C. holds. Some s that creates too many odd components when we delete s. S Odd component Even component

89 Tutte’s Theorem If G has a 1 factor, T.C. holds Pf: o(G-s)  |s| odd even distinct s

90 Tutte’s Theorem If T.C. holds, then G has a 1 factor Pf: Add an edge e G ’ satisfies T.C. (maybe has 1 factor) Complete graph. Certainly has 1 factor Keep adding G satisfies T.C but has no 1 factor 1: Adding e does not increase o(G-s), so T.C. still holds 2: If G’ has no 1 factor, then G has no 1 factor. So does the graph before G.

91 Tutte’s Theorem There exist a step ( the last graph without 1 factor) in which: Let G and G ’ be such graphs. Adding any edge e G ’ satisfies T.C. and has 1 factor G satisfies T.C but has no 1 factor

92 Tutte’s Theorem If G and G ’ are such graphs, we want to show that G also has 1-factor. Contradiction. U: degree = n(G)-1 U G-U

93 Case 1 If (G-U ) consist of only disjoint complete component. Let ’ s pair G  G has 1 factor U G-U complete Note: n(G) is even. Let s =  o(G-s) <= |s| Even component can pair by itself Odd component can pair by itself and one to U The left vertices are in U, and is even, can be paired in U.

94 Case 2 If (G-U ) is not a disjoint union of cliques. In (G-U) there exist: xz y w Not adjacent Distance = 2

95 Case 2 G + xz has 1 factor M1 ; G + yw has 1 factor M2 M1  M2 G x z w y M1M2

96 Case 2 G + xz has 1 factor M1 ; G + yw has 1 factor M2 M1  M2 :Only even cycles or isolated vertices G x z w y M1M2

97 Case 2 G + xz has 1 factor M1 ; G + yw has 1 factor M2 M1  M2 :Only even cycles or isolated vertices G x z w y Other cycle

98 Remark Parity | G-s| = parity o(G-s) O(G-s) +|s| has the same parity as n(G). O(G-s) -|s| has the same parity as n(G). If n(G) is even, and G has no 1-factor (thus o(G-s) > |s|) then at least 2.

99 Berge –Tutte Formula In general, o(G-s) > |s| for some s ( no perfect matching) The largest number of vertices saturated by a matching in G is : n(G) - d where d= max s  V(G) o(G - S)- |S|

100 2. o(G’-s’) = o(G-s)  |s| +d = |s’| G Berge –Tutte Formula G does not satisfy T.C. But G ’ = G  K d does. (  is Join), why? For all S ’  V(G’) Kd G’ 1. o(G’-s’)  1  |s’| S G ’ has perfect matching. Deleting Kd, back to G At most d matched turns to unmatched in G. Away from perfect by d i.e. n(G) – d

101 Petersen Therorem Every regular graph of even degree has a 2 – factor.

102 f-Factors of Graph Given a function f: V(G)  N  {0}, an f- factor of a graph g is a subgraph such that d H (v) = f(v) for all v  V(G) Assign degree to each vertex. f(w)  d(w) for all w. excess e = d – f.

103 Theorem A graph G has an f-factor if and only if its transform H has a 1-factor.

104 Edmonds’ Blossom Algorithm In Bipartite, APA is quick because we explore from each vertex at most once. For x  X, we can only reach via a saturated edge, hence only once can we reach x. In general graph, this doesn ’ t hold.

105 Edmonds’ Blossom Algorithm Edmond ’ s flower: For some x, if it can be reached from u via a saturated edge, and also via an unsaturated edge, then flower exist. x Stem Blossom

106 Edmonds’ Blossom Algorithm A blossom can be viewed as a super vertex. Saturated No other saturated can emerge from a blossom

107 Edmonds’ Blossom Algorithm S: via saturated, T: via unsaturated. A blossom can be detected if we go via unsaturated edge to a vertex S. Contract it. Later expand it.


Download ppt "Matching and Factors Matchings and Covers. Definitions: A matching M in a graph G is a set of non loop edges with no shared endpoints. G M."

Similar presentations


Ads by Google