Matching 4/21/2016. Bipartite Matching. 3330: Algorithms. First Try. Maximum Matching. Key Questions. Existence of Perfect Matching

Similar documents
Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Approximation Algorithms

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.

Matching Theory. Figure 1: Is this graph bipartite?

2. Lecture notes on non-bipartite matching

Graphs and Algorithms 2016

Theorem 2.9: nearest addition algorithm

5.1 Min-Max Theorem for General Matching

MC302 GRAPH THEORY Thursday, 10/24/13

Assignment 5: Solutions

Approximation Algorithms

Lecture 8: The Traveling Salesman Problem

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

List of Theorems. Mat 416, Introduction to Graph Theory. Theorem 1 The numbers R(p, q) exist and for p, q 2,

Coping with NP-Completeness

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

35 Approximation Algorithms

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

Graphs and Algorithms 2015

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

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

1 Matching in Non-Bipartite Graphs

Graph Algorithms (part 3 of CSC 282),

Institute of Operating Systems and Computer Networks Algorithms Group. Network Algorithms. Tutorial 4: Matching and other stuff

Graph Theory: Matchings and Factors

Matching and Covering

Approximation Algorithms

Lecture 4: Primal Dual Matching Algorithm and Non-Bipartite Matching. 1 Primal/Dual Algorithm for weighted matchings in Bipartite Graphs

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

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

Mathematical and Algorithmic Foundations Linear Programming and Matchings

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

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

MTL 776: Graph Algorithms Lecture : Matching in Graphs

Solving problems on graph algorithms

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

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

Notes for Recitation 9

NP-Hard (A) (B) (C) (D) 3 n 2 n TSP-Min any Instance V, E Question: Hamiltonian Cycle TSP V, n 22 n E u, v V H

1 The Traveling Salesperson Problem (TSP)

CS 4407 Algorithms. Lecture 8: Circumventing Intractability, using Approximation and other Techniques

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

1. Lecture notes on bipartite matching

Lecture 3: Graphs and flows

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

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

Figure 2.1: A bipartite graph.

GRAPH THEORY and APPLICATIONS. Matchings

Travelling Salesman Problem. Algorithms and Networks 2015/2016 Hans L. Bodlaender Johan M. M. van Rooij

Ma/CS 6b Class 2: Matchings

1 Matchings in Graphs

Traveling Salesman Problem. Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij

Graph Algorithms (part 3 of CSC 282),

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.

Design and Analysis of Algorithms

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

CSE 548: Analysis of Algorithms. Lecture 13 ( Approximation Algorithms )

Classic Graph Theory Problems

Minimum Spanning Trees

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

Algorithm Design and Analysis

CMPSCI611: The SUBSET-SUM Problem Lecture 18

Partha Sarathi Mandal

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs

Minimum Spanning Trees

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.

Chain Packings and Odd Subtree Packings. Garth Isaak Department of Mathematics and Computer Science Dartmouth College, Hanover, NH

Greedy algorithms Or Do the right thing

r=1 The Binomial Theorem. 4 MA095/98G Revision

2 Approximation Algorithms for Metric TSP

Exercise set 2 Solutions

Exam problems for the course Combinatorial Optimization I (DM208)

Advanced Methods in Algorithms HW 5

Paths, Trees, and Flowers by Jack Edmonds

Chapter 9 Graph Algorithms

Improved Approximations for Graph-TSP in Regular Graphs

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Chapter 9 Graph Algorithms

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

Topics in Combinatorial Optimization February 5, Lecture 2

Approximation Algorithms

Polynomial time approximation algorithms

CS521 \ Notes for the Final Exam

Ma/CS 6b Class 4: Matchings in General Graphs

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

Module 6 NP-Complete Problems and Heuristics

Graph Algorithms Matching

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

Notes for Lecture 24

Lecture 6: Graph Properties

MATH 682 Notes Combinatorics and Graph Theory II

Finding a -regular Supergraph of Minimum Order

11.4 Bipartite Multigraphs

Chapter 9 Graph Algorithms

Matching in Bipartite Graphs

1. a graph G = (V (G), E(G)) consists of a set V (G) of vertices, and a set E(G) of edges (edges are pairs of elements of V (G))

Outline. Graphs. Divide and Conquer.

Math 776 Graph Theory Lecture Note 1 Basic concepts

1 The Traveling Salesman Problem

Reference Sheet for CO142.2 Discrete Mathematics II

Transcription:

Bipartite Matching Matching 3330: Algorithms A graph is bipartite if its vertex set can be partitioned into two subsets A and B so that each edge has one endpoint in A and the other endpoint in B. A B A matching M is a subset of edges so that every vertex has degree at most one in M. 2 Maximum Matching First Try The bipartite matching problem: Find a matching with the maximum number of edges. Greedy method? (add an edge with both endpoints unmatched) u3 u4 A perfect matching is a matching in which every vertex is matched. v3 The perfect matching problem: Is there a perfect matching? 3 4 Key Questions Existence of Perfect Matching How to tell if a graph does not have a (perfect) matching? How to determine the size of a maximum matching? How to find a maximum matching efficiently? Hall s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that saturates A if and only if N(S) >= S for every subset S of A, where N(S) is the neighbors of S. S N(S) 5 6 1

Bound for Maximum Matching Algorithmic Idea? What is a good upper bound on the size of a maximum matching? Hall s Theorem [1935]: u3 u4 A bipartite graph G=(A,B;E) has a matching that saturates A if and only if N(S) >= S for every subset S of A. König [1931]: In a bipartite graph, the size of a maximum matching v3 is equal to the size of a minimum vertex cover. Any idea to find a larger matching? 7 8 Augmenting Path Optimality Condition What if there is no more M-augmenting path? If there is no M-augmenting path, then M is maximum! Prove the contrapositive: v3 v3 A bigger matching an M-augmenting path Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path whose endpoints are unmatched by M is an M-augmenting path. 1. Let M* be a maximal matching and M* > M. Consider 2. Every vertex in has degree at most 2 3. A component in is an even cycle or a path 9 4. Since, an M-augmenting path! 10 Algorithm Finding M-augmenting paths Key: M is maximum no M-augmenting path Orient the edges (edges in M go up, others go down) An M-augmenting path a directed path between two unmatched vertices How to find efficiently? v3 11 12 2

Faster Algorithms Complexity At most n/2 iterations An augmenting path in time by a DFS or a BFS Total running time Observation: Many short and disjoint augmenting paths. Idea: Find augmenting paths simultaneously in one search. 13 14 Application of Bipartite Matching General Matching Isaac Jerry Darek Tom Given a graph (not necessarily bipartite), find a matching with maximum total weight. Marking Tutorials Solutions Newsgroup Job Assignment Problem: Each person is willing to do a subset of jobs. Can you find an assignment so that all jobs are taken care of? unweighted (cardinality) version: a matching with maximum number of edges 15 16 Characterization of Perfect Matching Min-Max Theorem Hall s Theorem [1935]: A bipartite graph G=(A,B;E) has a matching that saturates A if and only if N(S) >= S for every subset S of A. König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Tutte s Theorem [1947]: A graph has a perfect matching if and only if o(g-s) <= S for every subset S of V, where o(g-s) is the number of connected components with an odd number of vertices in the subgraph G-S. Tutte-Berge formula [1958]: The size of a maximum matching = 17 18 3

Augmenting Path? Optimality Condition? What if there is no more M-augmenting path? If there is no M-augmenting path, then M is maximum? Prove the contrapositive: v3 v3 A bigger matching an M-augmenting path Given a matching M, an M-alternating path is a path that alternates between edges in M and edges not in M. An M-alternating path whose endpoints are unmatched by M is an M-augmenting path. 1. Consider 2. Every vertex in has degree at most 2 3. A component in is an even cycle or a path 4. Since, an M-augmenting path! Works for general graphs. 19 20 Algorithm? Finding Augmenting Path in Bipartite Graphs Key: M is maximum no M-augmenting path Orient the edges (edges in M go up, others go down) edges in M having positive weights, otherwise negative weights How to find efficiently? v3 In a bipartite graph, an M-augmenting path corresponds to a directed path. 21 22 Finding M-augmenting paths in General Graphs Don t know how to orient the edges so that: an M-augmenting path an alternating path between two free vertices v 0 v 7 v3 Complexity At most n/2 augmentations. Each augmentation does at most n contractions. An alternating walk can be found in O(m) time. Total running time is O(mn 2 ). v7 v6 v5 An operation called Contraction is needed. 23 24 4

Weighted Bipartite Matching Weighted Bipartite Matching Given a weighted bipartite graph, find a matching with maximum total weight. A B Not necessarily a maximum size matching. 25 Wlog, assume perfect matching on complete bipartite graph; (add fictitious edges with weights 0) 26 First Algorithm First Algorithm Find maximum weight perfect matching Orient the edges (edges in M go up, others go down) edges in M having positive weights, otherwise negative weights How to know if a given matching M is optimal? Idea: Imagine there is a larger matching M* and consider the union of M and M* v3 Then M is maximum if and only if there is no negative cycles 27 28 First Algorithm Key: M is maximum no negative cycle Complexity At most nw iterations A negative cycle in O(n 3 ) time by Floyd Warshall Total running time O(n 4 W) Can choose minimum mean cycle to avoid W How to find efficiently? 29 30 5

Traveling salesman problem Near Optimal solution Faster Easier to implement. EULER CYCLE Given a graph, G, find a cycle that visits every edge exactly once Necessary & Sufficient Condition: G is connected and every vertex is even degree. Algorithm (O(n 2 )): 1. Repeatedly use DFS to find and remove a cycle from G 2. Merge all the cycles into one cycle. 31 Euclidian Traveling Salesman Problem Euclidian Traveling Salesman Problem MST APPROX-TSP-TOUR2(G, c) 1 Select a vertex r Є V[G] to be root. 2 Compute a MST T for G from root r using Prim Alg. 3 Find a minimal-weight matching M for vertices of odd degree in T. 4 Find an Euler cycle C in G = (V, T U M). 5 L=list of vertices in preorder walk of C. 6 return the Hamiltonian cycle H in the order L. Euler Cycle Add Min Matching HAM-Cycle 33 34 Time Complexity APPROX-TSP-TOUR2(G, c) 1 Select a vertex r Є V[G] to be root. 2 Compute a MST T for G from root r using Prim Alg. 3 Find a minimal-weight matching M for vertices of odd degree in T. 4 Find an Euler cycle A in G = (V, T U M). 5 L=list of vertices in preorder walk of A. 6 return the Hamiltonian cycle H in order L. O(1) O(n lg n) O(n 4 ) O(n 2 ) O(n) O(n) Traveling salesman problem This is polynomial-time 3/2-approximation algorithm. (Why?) Because: APPROX-TSP-TOUR2 is O(n 4 ) C(MST) C(H*) Optimal H*: optimal soln C(A) = C(MST)+C(M) A: Euler cycle C(M) 0.5C(H*) M: min matching C(H) C(M) H: approx soln & C(H) 1.5C(H*) triangle inequality Euler cycle Solution 35 36 6

Proof of C(M) 0.5C(H*) Let optimal tour be H*: j 1 i 1 j i i 2 j k i 2m {i 1,i 2,,i 2m }: the set of odd degree vertices in T. Define 2 matchings: M 1 ={[i 1,i 2 ],[i 3,i 4 ],,[i 2m-1,i 2m ]} M 2 ={[i 2,i 3 ],[i 4,i 5 ],,[i 2m,i 1 ]} M is min matching: C(M) C(M1) and C(M) C(M2) By triangle inequality: C(H*) length(m 1 ) + length(m 2 ) 2 length(m) C(M) 1/2 C(H*) 7