Matchings in Graphs. Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1.

Similar documents
Matching Theory. Figure 1: Is this graph bipartite?

1 Matchings in Graphs

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Lecture 3: Graphs and flows

Module 7. Independent sets, coverings. and matchings. Contents

1 Matching in Non-Bipartite Graphs

5.1 Min-Max Theorem for General Matching

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Lecture 10 Graph algorithms: testing graph properties

Advanced Algorithms Class Notes for Monday, October 23, 2012 Min Ye, Mingfu Shao, and Bernard Moret

Mathematical and Algorithmic Foundations Linear Programming and Matchings

Topics in Combinatorial Optimization February 5, Lecture 2

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

Advanced Combinatorial Optimization September 17, Lecture 3. Sketch some results regarding ear-decompositions and factor-critical graphs.

Modules. 6 Hamilton Graphs (4-8 lectures) Introduction Necessary conditions and sufficient conditions Exercises...

Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching. A maximal matching cannot be enlarged by adding another edge.

PERFECT MATCHING THE CENTRALIZED DEPLOYMENT MOBILE SENSORS THE PROBLEM SECOND PART: WIRELESS NETWORKS 2.B. SENSOR NETWORKS OF MOBILE SENSORS

MTL 776: Graph Algorithms Lecture : Matching in Graphs

Lecture 8: PATHS, CYCLES AND CONNECTEDNESS

Sources for this lecture. 3. Matching in bipartite and general graphs. Symmetric difference

Matchings. Saad Mneimneh

Lecture notes on: Maximum matching in bipartite and non-bipartite graphs (Draft)

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Exercise set 2 Solutions

Algorithms: Lecture 10. Chalmers University of Technology

val(y, I) α (9.0.2) α (9.0.3)

Assignment 4 Solutions of graph problems

Topics on Computing and Mathematical Sciences I Graph Theory (3) Trees and Matchings I

2. Lecture notes on non-bipartite matching

Key Graph Theory Theorems

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

5 Matchings in Bipartite Graphs and Their Applications

Copyright 2000, Kevin Wayne 1

Ma/CS 6b Class 2: Matchings

Finding Strongly Connected Components

implementing the breadth-first search algorithm implementing the depth-first search algorithm

Approximation slides 1. An optimal polynomial algorithm for the Vertex Cover and matching in Bipartite graphs

A note on isolate domination

Advanced Combinatorial Optimization September 15, Lecture 2

Fundamental Properties of Graphs

The External Network Problem

AMS /672: Graph Theory Homework Problems - Week V. Problems to be handed in on Wednesday, March 2: 6, 8, 9, 11, 12.

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

1. Lecture notes on bipartite matching

Lecture 7. s.t. e = (u,v) E x u + x v 1 (2) v V x v 0 (3)

Notes for Lecture 20

1 The Arthur-Merlin Story

Computer Science 280 Fall 2002 Homework 10 Solutions

Coloring. Radhika Gupta. Problem 1. What is the chromatic number of the arc graph of a polygonal disc of N sides?

Discrete mathematics , Fall Instructor: prof. János Pach

Lecture 10,11: General Matching Polytope, Maximum Flow. 1 Perfect Matching and Matching Polytope on General Graphs

12.1 Formulation of General Perfect Matching

Number Theory and Graph Theory

Solving problems on graph algorithms

On the Relationships between Zero Forcing Numbers and Certain Graph Coverings

K 4 C 5. Figure 4.5: Some well known family of graphs

[Ramalingam, 4(12): December 2017] ISSN DOI /zenodo Impact Factor

LECTURES 3 and 4: Flows and Matchings

8 Matroid Intersection

and 6.855J March 6, Maximum Flows 2

9.1 Cook-Levin Theorem

WUCT121. Discrete Mathematics. Graphs

CS261: Problem Set #1

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

Lecture 6: Faces, Facets

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Paths, Flowers and Vertex Cover

Graph Algorithms. Imran Rashid. Jan 16, University of Washington

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Small Survey on Perfect Graphs

Vertex 3-colorability of claw-free graphs

1 The Traveling Salesperson Problem (TSP)

CS781 Lecture 2 January 13, Graph Traversals, Search, and Ordering

Jessica Su (some parts copied from CLRS / last quarter s notes)

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Graph Theory Mini-course

CPSC 536N: Randomized Algorithms Term 2. Lecture 10

Finite Termination of Augmenting Path Algorithms in the Presence of Irrational Problem Data

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

Two Characterizations of Hypercubes

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

1 Bipartite maximum matching

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

1 Undirected Vertex Geography UVG

ON VERTEX b-critical TREES. Mostafa Blidia, Noureddine Ikhlef Eschouf, and Frédéric Maffray

1 Variations of the Traveling Salesman Problem

Algorithm and Complexity of Disjointed Connected Dominating Set Problem on Trees

Math 776 Graph Theory Lecture Note 1 Basic concepts

1 Random Walks on Graphs

Theorem 2.9: nearest addition algorithm

Chapter 5 Graph Algorithms Algorithm Theory WS 2012/13 Fabian Kuhn

Matchings, Ramsey Theory, And Other Graph Fun

Network flows and Menger s theorem

Faster parameterized algorithms for Minimum Fill-In

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

Solutions for the Exam 6 January 2014

Approximation Algorithms: The Primal-Dual Method. My T. Thai

Transcription:

Lecturer: Scribe: Meena Mahajan Rajesh Chitnis Matchings in Graphs Meeting: 1 6th Jan 010 Most of the material in this lecture is taken from the book Fast Parallel Algorithms for Graph Matching Problems by Karpinski and Rytter, [KR98]. We will only be considering simple undirected finite graphs unless stated otherwise. Graphs will be denoted as G = (V, E). 1 Some preliminary definitions Definition 1 Let G = (V, E) be a graph. M E is called as a matching of G if v V we have {e M : v is incident on e E} 1. Definition A matching M of G is said to be maximal if e E \ M the set of edges given by M {e} is not a matching of G. Definition 3 The size of a matching M of G is the number of the edges it contains and is denoted by M. Definition 4 A matching M of G is said to be maximum if matching M of G we have M M. A maximum matching is always maximal but not vice-versa. Definition 5 Let M be matching of G. A vertex v V is said to be M-saturated if M contains an edge incident on v. Otherwise v is said to be M-unsaturated or M-free. Definition 6 A matching M of G is said to be perfect if all vertices of G are M-saturated. A graph with an odd number of vertices can never admit a perfect matching. Definition 7 A matching M of G is said to be near-perfect if exactly one vertex of G is M-unsaturated. A graph with an even number of vertices can never admit a near-perfect matching. Definition 8 Let A V. A matching M of G is said to be A-perfect if each vertex in A is M-saturated. A perfect matching is a V -perfect matching. 1

Some Remarks Remark 9 We will later look at weighted graphs i.e graphs with a weight function w : E R + {0}. There we will be interested in finding matchings of maximum weight where the weight of a matching is the sum of weights of edges which are in the matching. Remark 10 We will consider three types of problems Decision - Does G have a matching of size k? Search - Find a matching in G of size k Counting - How many matchings of G have size k? 3 Augmenting Paths Definition 11 A path P in G is said to be M-alternating if the edges of P alternate with respect to membership in M. Definition 1 A path P in G is said to be M-augmenting if P is a maximal M-alternating path starting and ending at vertices which are M-unsaturated. Clearly, every M-augmenting path must have odd length (number of egdes). Lemma 13 Let G be a graph whose maximum degree is atmost. Then every component of G is either an isolated point, a path or a cycle. Proof: Consider any non-isolated vertex v of G. Its (at most two) neighbours further have degree at most and so on. So the component of G containing v is either a path or a cycle. This holds true for all non-isolated vertices of G and hence we are done. Lemma 14 (Berge 1957) A matching M is maximum if and only if G has no M-augmenting path. Proof: Suppose there exists an M-augmenting path P. Consider the symmetric difference M P ( edges which are present in exactly one of M or P ). Since P is an M-augmenting path, M P is also a matching of G and M P = M + 1. So M is not maximum. Suppose M is not maximum. Let M be a maximum matching and so we have M > M. Consider M M. Each vertex has degree at most in M M as each of M and M can contribute atmost 1 each to degree of each vertex in M M. By Lemma 13, M M consists of cycles and paths and isolated vertices. But edges of M M are alternate in belonging exclusively to M and M. Hence each cycle must be even. So M can score over M in size only from the paths. So, there exists at least one path in M M which has more edges from M than from M. But such a path is M-augmenting.

Corollary 15 (Hopcroft-Karp) Let M be a matching of G. Then for any matching M of G such that M M, we have M M vertex-disjoint M-augmenting paths. The non-m edges on these paths all belong to M. Proof: Refer to proof of Lemma 14. Every cycle of M M is even and every path of M M which is not M-augmenting must have equal number of edges from M and M as M is maximum. Also note that each M-augmenting path has exactly one edge more from M than from M. So we need M M such paths; these are all vertex-disjoint as we defined augmenting paths as maximal paths starting and ending at unsaturated points (see Definition 1). Corollary 16 Let M be a maximum matching and M be any matching. If M is not maximum, then the shortest M-augmenting path has length V M M 1 Proof: From Corollary 15 we know that there are M M vertex-disjoint (and hence edge-disjoint) M-augmenting paths. By Pigeonhole Principle, one of the paths must have at V most vertices and thus has length at most V 1. M M M M 4 Algorithm for finding maximum matching using augmenting paths Consider the following algorithm; its correctness follows immediately from Lemma 14. 1. M =. while there is an M-augmenting path P do M M P 3. return M The challenge now is to detect existence of and find augmenting paths efficiently. We will first consider the case when G is bipartite. 5 An O(n 3 ) algorithm for finding maximum matching in bipartite graphs Let G = (A B, E) be a bipartite graph and let M be a matching of G. We want to find a maximum matching of G. Denote by A 0, B 0 the sets of M-unsaturated vertices in A, B respectively. We consider a new directed graph H on the vertex set A B and edge set E. Edges which are in M are directed A B and edges not in M are directed B A. 3

Claim 17 G has a M-augmenting path if and only if H has a path from B 0 to A 0. Proof: Suppose G has an M-augmenting path say from u A 0 to v B 0. The same path directed from v to u is clearly a path in H from B 0 to A 0. Suppose H has a path from b B 0 to a A 0. The underlying undirected path from a to b is clearly an M-augmenting path. So we do a depth-first-search (DFS) from B 0 and stop as soon as we reach some vertex in A 0, thus giving us an M-augmenting path P. We then augment M along P, and repeat the same process with the new matching M P. If we cannot reach any vertex of A 0, then we can conclude from Claim 17 that G has no M-augmenting path i.e. M is maximum. Let us now analyse the time complexity of our algorithm. Denote V = n and E = m. 1. Assume B A as otherwise we could have just swapped the roles of A and B in our algorithm. Thus B 0 B n. Also at each stage of our algorithm, by augmenting, we saturate a previously-unsaturated vertex from B without doing anything to the vertices which are already saturated. So we need at most B 0 n stages.. At each stage we may need to do several DFS, one starting from each vertex in B 0. The maximum number of times we need to do DFS is B 0, as in the worst-case, only the last vertex from B 0 that we apply DF S to may lead to a path in A 0. Recollect that a single DF S can be done in O(n + m) time. 3. Once an augmenting path is found, we can augment the matching easily in O(m) time. Thus the Total Time taken by algorithm is at most n [ ] O(m) + B 0 O(n + m). However now we use a trick to shave off the B 0 factor. Add a super-vertex β and draw edges directed from β to every point in B 0.( Thus we need to apply DFS only once, for vertex β. Thus the n ) ( ) time complexity becomes O [m + (n + m)] = O n + nm. Since a bipartite graph on n vertices can contain at most ( n 4 ) edges, the time complexity of our algorithm is O(n3 ). 6 Hopcroft-Karp Algorithm for finding a maximum matching in bipartite graphs in O(n.5 ) time In the preceding algorithm, we looked for a single augmenting path at a time and augmented it. Instead we will now find a maximal family of vertex-disjoint shortest-length augmenting paths and augment all of them together in a single stage. This improvement will help us to bring the time complexity down to O(n.5 ). 4

Consider the following algorithm. 1. M =. while (there is an M-augmenting path), do find a maximal family F of vertex-disjoint shortest M-augmenting paths); set M M F 3. return M The correctness of the algorithm follows from Lemma 14. We now show that using a maximal family F of shortest augmenting paths instead of a single augmenting path significantly reduces the number of stages (Lemma 1), and also that the time per stage due to having to find such families does not increase (Lemma ). We need some technical lemmas. Lemma 18 Let M be a matching of G and let P be an M-augmenting path of shortest length. Let P be an (M P )-augmenting path. Then P P + P P, where P is the number of edges in P. Proof: Consider N = (M P ) P. Then N is clearly a matching and N = M +. Thus by Corollary 15, there are vertex-disjoint M-augmenting paths, say P 1 and P, with the non-m edges in N. That is, P 1 P M N. Note that M N = P P and thus we have P P P 1 + P. But P 1, P are both M-augmenting paths and P is a shortest M-augmenting path. Therefore P P P. However P P = P + P P P and so the desired inequality follows. Lemma 19 Let M 0 =, and consider the sequence M 0, M 1, M, M 3,... where i, P i is a shortest M i -augmenting path, and M i+1 = M i P i. Then, for i < j, P i P j. Further, P i = P j implies that P i and P j are vertex-disjoint. Proof: It follows from Lemma 18 that for i < j, P i P j. Suppose now that for some i < j, P i and P j are not vertex-disjoint, and assume to the contrary that P i = P j. This implies that P i = P i+1 =... = P j 1 = P j. Then there exist some k, l such that i k < l j and P k and P l are not vertex-disjoint and further for all m between l and k we have P m is vertex-disjoint from both P k and P l. Therefore P l is an (M k )-augmenting path and so by Lemma 18 we have P l P k + P l P k. However we are given that P l = P k which implies that P l P k = 0 i.e. P l and P k have no edges in common. However since P l and P k are not vertex-disjoint, they have a common vertex say x and then they must have in common the edge from M k P k which is incident on x leading to a contradiction. 5

Lemma 0 Let F be an inclusion-maximal family of vertex-disjoint shortest M-augmenting paths, all of length l 1. Let l be the length of a shortest (M F)-augmenting path. Then l l 1 +. Proof: Let F = {P 1, P,.., P r }. Let P be a shortest (M F)-augmenting path. Note that M F = (..(M P 1 ) P )..) P r. Suppose P is disjoint from each element of F. Then P is also an M-augmenting path, but by maximality of F, it is not a shortest augmenting path. So l > l 1. Next, suppose that P has a vertex in common with at least one path in F. By Lemma 19 we have l > l 1. Finally note that l 1, l are both lengths of augmenting paths and hence must both be odd; hence l > l 1 = l l 1 +. Let us look at the graph H considered at beginning of Section 5. Let A B = n and E = m. Note that Claim 17 holds. Lemma 1 The algorithm described at start of Section 6 makes atmost n iterations Proof: Let M be a maximum matching and let M be the matching after n iterations. By Lemma 0, the length of the shortest M-augmenting path is at least ( n 1) n. By Corollary 16 we have n n (length of shortest M-augmenting path), and so M M M M n. From this point onwards, even if we augment just one path in each iteration, we need at most n more iterations, as each augmenatation increases size of matching by 1. Thus overall we need no more than n iterations. iterations Lemma Each iteration of the algorithm can be implemented in O(m) time. Proof: First we will use breadth-first-search BFS to find the length k of a shortest path from B 0 to A 0. Simultaneosuly, we produce the sequence of disjoint layers B 0 = L 0, L 1, L,..., L k A 0 where for all 0 i < k, L i is the set of vertices at distance i from B 0, and L k is the subset of A 0 which is at distance k from B 0. To avoid multiple BFSs from each vertex in B 0, we add a super-vertex β and draw edges from it to all vertices of B 0. Start a BF S from β to get distance of β from A 0. Subtract one to get length of shortest path from B 0 to A 0. This takes O(m) time. Now consider a modified DF S which starts at a vertex v B 0 and stops as soon as it reaches a vertex say w in L k and outputs this v w path. Add this M-augmenting path to F and delete all vertices visited in the modified DF S. This is crucial: we delete not just the augmenting path but also other vertices visited in the modified DFS. Why is this reasonable? Let x be a vertex seen at some L j in the DFS started from v B 0. If x does not lead to an M-augmenting path of length k starting at v, then x cannot be on any M-augmenting path of length k: any such path has to begin at some vertex in B 0 and it has to use i edges to reach x. 6

Redo the whole procedure now starting at another vertex in B 0. Continue until all vertices of B 0 are explored. This clearly gives us a maximal family of vertex-disjoint shortest-length augmenting paths. Let m i be the number of edges visited in the i th DFS which takes O(m i ) time. Noting that m i m i, the time taken is O(m). Theorem 3 The algorithm runs in O(n.5 ) time. Proof: From Lemma we know that each phase can be implemented in O(m) time. Also from Lemma 1 we know that there are atmost n iterations. Thus time taken by our algorithm is O( n) O(m) = O(n.5 ) References [KR98] Marek Karpinski and Wojciech Rytter. Fast parallel algorithms for graph matching problems. Oxford University Press, Oxford, 1998. Oxford Lecture Series in Mathematics and its Applications 9. 7