6 Maximum Matching. CS105 Maximum Matching Winter Consider an undirected graph G = (V, E).

Similar documents
Approximation Algorithms

CMPSCI611: Approximating MAX-CUT Lecture 20

Midterm Practice Problems

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, Chapter 7: Digraphs

Analysis of Algorithms, I

Triangle deletion. Ernie Croot. February 3, 2010

The Goldberg Rao Algorithm for the Maximum Flow Problem

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

5.1 Bipartite Matching

Simple Graphs Degrees, Isomorphism, Paths

Lecture 17 : Equivalence and Order Relations DRAFT

THE PROBLEM WORMS (1) WORMS (2) THE PROBLEM OF WORM PROPAGATION/PREVENTION THE MINIMUM VERTEX COVER PROBLEM

Introduction to Graph Theory

Graph Theory Problems and Solutions

Institut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie. An Iterative Compression Algorithm for Vertex Cover

Max Flow, Min Cut, and Matchings (Solution)

Connectivity and cuts

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

Tree-representation of set families and applications to combinatorial decompositions

6.2 Permutations continued

A Sublinear Bipartiteness Tester for Bounded Degree Graphs

P. Jeyanthi and N. Angel Benseera

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Part 2: Community Detection

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

8. Matchings and Factors

3. Eulerian and Hamiltonian Graphs

Class One: Degree Sequences

Algorithm Design and Analysis

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

SEMITOTAL AND TOTAL BLOCK-CUTVERTEX GRAPH

Euler Paths and Euler Circuits

Network Flow I. Lecture Overview The Network Flow Problem

5 Directed acyclic graphs

GRAPH THEORY LECTURE 4: TREES

Disjoint Compatible Geometric Matchings

Social Media Mining. Graph Essentials

8.1 Min Degree Spanning Tree

Scheduling Shop Scheduling. Tim Nieberg

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Generating models of a matched formula with a polynomial delay

SOLUTIONS TO ASSIGNMENT 1 MATH 576

Distributed Computing over Communication Networks: Maximal Independent Set

Generalized Induced Factor Problems

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

Approximated Distributed Minimum Vertex Cover Algorithms for Bounded Degree Graphs

Graphs without proper subgraphs of minimum degree 3 and short cycles

each college c i C has a capacity q i - the maximum number of students it will admit

BOUNDARY EDGE DOMINATION IN GRAPHS

Tools for parsimonious edge-colouring of graphs with maximum degree three. J.L. Fouquet and J.M. Vanherpe. Rapport n o RR

Problem Set 7 Solutions

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Computer Science Department. Technion - IIT, Haifa, Israel. Itai and Rodeh [IR] have proved that for any 2-connected graph G and any vertex s G there

Data Structures Fibonacci Heaps, Amortized Analysis

CIS 700: algorithms for Big Data

SCAN: A Structural Clustering Algorithm for Networks

Every tree contains a large induced subgraph with all degrees odd

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Definition Given a graph G on n vertices, we define the following quantities:

INCIDENCE-BETWEENNESS GEOMETRY

Arrangements And Duality

On the k-path cover problem for cacti

Applied Algorithm Design Lecture 5

Cycles and clique-minors in expanders

6.3 Conditional Probability and Independence

Small Maximal Independent Sets and Faster Exact Graph Coloring

Chapter 6: Graph Theory

Automata and Computability. Solutions to Exercises

Semi-Matchings for Bipartite Graphs and Load Balancing

On the Unique Games Conjecture

Network (Tree) Topology Inference Based on Prüfer Sequence

1 if 1 x 0 1 if 0 x 1

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

Removing Even Crossings

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. The Independent Even Factor Problem

Mining Social Network Graphs

Full and Complete Binary Trees

Finding and counting given length cycles

Fairness in Routing and Load Balancing

Lecture 16 : Relations and Functions DRAFT

Optimal Index Codes for a Class of Multicast Networks with Receiver Side Information

Dimitris Chatzidimitriou. Corelab NTUA. June 28, 2013

UPPER BOUNDS ON THE L(2, 1)-LABELING NUMBER OF GRAPHS WITH MAXIMUM DEGREE

Network Algorithms for Homeland Security

Approximating Minimum Bounded Degree Spanning Trees to within One of Optimal

Lecture 1: Course overview, circuits, and formulas

Cycles in a Graph Whose Lengths Differ by One or Two

Odd induced subgraphs in graphs of maximum degree three

Data Structures and Algorithms Written Examination

Labeling outerplanar graphs with maximum degree three

ON INDUCED SUBGRAPHS WITH ALL DEGREES ODD. 1. Introduction

Small independent edge dominating sets in graphs of maximum degree three

Cycle transversals in bounded degree graphs

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Solutions to Homework 6

Non-Separable Detachments of Graphs

On Integer Additive Set-Indexers of Graphs

Determination of the normalization level of database schemas through equivalence classes of attributes

Transcription:

6 Maximum Matching Consider an undirected graph G = (V, E). Definition: A matching, M, of G is a subset of the edges E, such that no vertex in V is incident to more that one edge in M. Intuitively we can say that no two edges in M have a common vertex. Maximal Matching: A matching M is said to be maximal if M is not properly contained in any other matching. Formally, M M for any matching M of G. Intuitively, this is equivalent to saying that a matching is maximal if we cannot add any edge to the existing set. Maximum Matching: A matching M is said to be Maximum if for any other matching M, M M. M is the maximum sized matching. Theorem 1 If a matching M is maximum M is maximal Proof: Suppose M is not maximal M such that M M M < M M is not maximum Therefore we have a contradiction. The converse of the above is not true. We see this using the counter example below: 1

(a) is the original graph. (b) is a maximal matching but not the maximum matching (c) Maximal matching for a given graph can be found by the simple greedy algorithn below: Maximal Matching(G, V, E) 1. M = φ 2.While(no more edges can be added) 2.1 Select an edge,e,which does not have any vertex in common with edges in M 2.2 M = M e 3. returnm 6.1 Augmenting Paths We now look for an algorithm to give us the maximum matching. Definition: Matched Vertex: Given a matching M, a vertex, v is said to be matched if there is an edge e M which is incident on v. Definition:Augmenting Path:Given a graph, G = (V, E) and a matching M E a path P is called an augmenting path for M if: 1. The two end points of P are unmatched by M. 2. The edges of P alternate between edges M and edges M. Theorem 2 (Berge s Theorem) A matching M is maximum iff it has no augmenting path. 2

Proof : We first prove the forward implication, M is maximum M has no augmenting path. If M has an augmenting path,p, then switch the edges along the path P from in-to-out of M and vice-versa. (We will represent this switching operation as M P ). This gives a matching with one more edge. Thus, M could not have been maximum. Now we prove the reverse implication, no augmenting path M is maximum By contrapositive, M is not maximum M has an augmenting path Let M be a matching such that M > M Consider the sub-graph of G induced by M M, including the edges that appear in M M twice. Let H be this multi-graph. vertex v H, deg H (v) 2 (Because any vertex has atmost 2 edges one from M and one from M incident on it.) Therefore, any connected component of H must be either a path or a cycle. The cycles preent in this graph must be of even length because otherwise two edges of the same component M or M will be adjacent to each other and this will violate the assumption that the original set M (or M ) was a matching. There are 6 different possiblities for the components of H. which are listed below (and shown in the figure): The components above can be classifies as follows: 1. An isoated vertex. 2. A 2-cycle 3. A larger alternating cycle of even length. 4. An even length path 5. An odd length path starting (and ending) with a vertex in M. 6. An odd length path starting (and ending) with a vertex in M. The solid edges represent the edges from M and the dashed edges represent the edge from M 3

Now, we know that M > M so there must be more dashed edges than solid edges. Of the above components only 5 and 6 have different number of dashed and solid edges (different no. of edge from M and M ).Also 5 is the component which has more edges from M than from M. For M > M atleast one component of type 5 must be present. (Infact more components of type 5 than 6 but we can do with the weaker statement above). However, even if one such component is present we have an augmenting path w.r.t. M. Thus we have shown that if M is not maximum then there is an augmenting path w.r.t. M. Note: The maximum matching for a graph need not be unique. Using the above result we can write the ouline for an algorithm to find the maximum matching. 4

Maximum Matching (G, M) 1. M φ 2. While ( an augmenting path P ) 2.1 M M p 3. return M For the above algorithm we need an algorithm to find an augmenting path. In the sections to follow we will write a rough outline for such an algorithm. This will lead us to two cases which need separate handling. 1. The problem for bipartite graphs. 2. The problem for a general graph. In the subsequent sections we will handle those problem individually 6.2 Intuitive idea for finding the Maximum Matching in a graph In this section we look at a very simple idea to obtain a maximum matching in a graph G. As we see later the algorithm does not work in the general case. The idea, however, can be modified to treat cases separately. Idea: With an unmatched vertex as the root start a DFS. Keep track of the distance of any node from the root as we perform the DFS. If the current node is at an odd distance use an edge M to continue the DFS else use an edge M. If at any point we find an unmatched vertex adjacent to a vertex at an even distance we have an augmenting path. Intuitively, the idea is good because starts with an unmatched vertex and alternates between edges in M and not present in M. This approach however does not guarentee that an augmenting path will be found if there exists one. Consider the following graph. Lets start the DFS with 6 as the root node. If we take the following path for the DFS: 6-5-4-3-2-1 we find an augmenting path. However, we miss the augmenting path if we take the following order for the DFS: 6-2-3-4-5. 5

The problem case for this method is the presence of odd cycles in a graph. In an odd cycle there will be two unmatched edges that share a vertex. If the DFS is started from that vertex and the cycle is traveresed the wrong way we will miss the augmenting path. To curcumvent this problem, in the next section we assume that G has no odd cycles i.e. G is bipartite. The case for a general graph will be considered in the subsequent section. 6.3 Maximum Matching for a bipartite graphs We assume G = (V, E) has no odd cycle i.e. G is bipartite. Then we can divide V into two partitions,l and R such that (u, v) E,u L v R. Then the previous algorithm can be modified as: Bipartite Matching(G, M) 1. Start DFS at a vertex in L. 2. If current vertex is in L follow an edge,e M else follow an edge, e M If at any point we find an unmatched verted R then augmenting path is found. Analysis: V = n, E = m. Time = (no. of iterations) (time per iteration) 6

= n 2.m = O(mn) For efficiency reasons we improve on the algorithm presented previously. Let U V be the set of unmatched vertices in G for a given matching M. Initially we label all the vertices in U as even. We can regard U as a forest, F u. We grow this forest, with every vertex of U in a component, as follows: 1. Find an edge connecting an even vertex in F u to a matched vertex v outside F u. Let v be the neighbour of V in M. 2. F = F (u, v) (v, v ). Label v as odd and v as even. This can be seen more clearly in the figure below. As can be seen this graph grows as an alternating cycle. Ultimately, we will come to a stage where we cannot add anything more to any component. At this stage if there are edges present between two even edges we have an augmenting path. Also these two edges must belong to different components of the forest as G has no odd cycles. Summing up we have the following algorithm for finding a maximum matching. 7

Forest Growing Matching(G) 1. Randomly selected any matching, M. 2. do 2.1 Grow forest as above, labelling the vertices even / odd 2.2 Find all such even - even edges to obtain a maximally disjoint set of augmenting paths (P 1, P 2,..., P k ). 2.3 M M P 1 P 2 P k while( an augmenting path) Analysis We need to run atmost O( n) iterations and each iteration takes O(m) time. Thus the running time of this algorithm is O(m n). 6.4 Maximum Matching for general graphs Definition: Blossom: A blossom is defined as a cycle of odd length (2k + 1 edges) with k matching edges. Lemma 1 (Cycle Shrinking Lemma): 1 Let M be a matching of G and B be a blossom. Further, assume that B is vertex-disjointed from (i.e. has no vertex in common) with the rest of M. Consider the graph G obtained by contracting B to a single vertex. Then the matching M of G induced by M is maximum in G iff M is maximum in G. Proof: M is maximum M is maximum Suppose M is not maximum in G. Then there is an augmenting path P w.r.t. M in G. Suppose P does not intersect the blossom,b, in G, then P is also an augmenting path in G and hence M is not maximum. So P must intersect B in G. In particular, the contracted blossom, B, must be an end point of P in G since B is vertex-disjointed from M (and so otherwise there will be two consecutive edges in P M ). Let P meet B at the vertex v, and let u be the unmatched vertex in the blossom 2. Let P be the path from v to u in the blossom that begins with the matching edge incident to v. Then, P = P P is an augmenting path in G and so, again M is not a maximum matching. 1 The definition and some parts of the proof are borrowed from Sanosh Vempala s notes 2 In a blossom (vertex-disjointed) there will be exactly one unmatched vertex 8

Thus, if M is maximum then M is maximum. Now consider the converse, M is maximum M is maximum. If M is not maximum then by Berge s theorem there must be an augmenting path P in G. Following a similar argument as above we assume that P intersects the blossom B. Since B contains only one unmatched vertex atleast one end-point of P must lie outside B. Let w be this point. Consider the path P obtained by starting at w and following P until it intersects the blossom. P is an augmenting path in G and thus M could not have been maximum. Hence, we have the proof of the lemma. To find an augmenting path in a general graph we detect and contract any blossom we find with the knowledge that by the cycle shrinking lemma the maximum matching in the shrunk graph will give us the maximum matching in the original graph. To obtain a maximum matching we use the same forest growing algorithm as for the bipartite graphs. After growing the forest we consider the neighbourhood of the even vertices. The following cases come up: 1. If two even vertices from different components are adjacent, then there is an augmenting path between the roots of the components. 2. If two even vertices from the same component are adjacent then there is a blossom,b, that is present. Let P be the path connecting B to the root. We get an equivalent sized matching from M M P. After this B is vertex disjointed with M and we can apply the cycle-shrinking lemma to it. So we shrink B and obtain a new graph G and we start all over again on G. 3. If every even vertex is adjacent only to odd vertices we already have a maximum matching. To see this, let p be the odd vertices and q be the even vertices. Then there are (q p) components in the forest. Any mathcing will have atleast q p unmatched vertices and so the matching we have must be maximum. Thus summing it all up we have an algorith for maximum matching for a general graph. Maximum Matching(G) 1. Randomly selected any matching, M. 9

2. do 2.1 Grow forest as described, labelling the vertices even / odd 2.2 if (there is a blossom in the graph) shrink the blossom to obtain a new graph G continue else Find all such even - even edges to obtain a maximally disjoint set of augmenting paths (P 1, P 2,..., P k ). 2.3 M M P 1 P 2 P k while( a blossom an augmenting path) 3. Expand all blossoms to obtain the maximum matching in the original graph Analysis: We can haveo(n) augmenting paths so there are O(n) iterations of the loop in the forest growing algortihm. For every augmenting path we find we can have O(n) blossoms to shrink. At each level it takes O(m) work to identify a blossom or an augmenting path. Therefore, the work done to reduce the graph and find the maximum matching = O(mn 2 ). Expanding any blossom can be done in 0(m) time so the total work done expanding = O(mn 2 ). Therefore the entire algorithm takes time = O(mn 2 ). 6.5 Historical Significance In his paper describing the above algorithm, Edmonds defined the notion of polynomialrunning time for an efficient algorithm. 10