680 likes | 1.15k Views
CS6234: Lecture 1. Matching in Graph Matching in Bipartite Graph [PS82]-Ch10 Matching in General Graphs [PS82]-Ch10 Weighted Matching in Bipartite Graph [PS82]-Ch 11.1—11.2 Additional topics: Reading/Presentation by students.
E N D
CS6234: Lecture 1 • Matching in Graph • Matching in Bipartite Graph [PS82]-Ch10 • Matching in General Graphs [PS82]-Ch10 • Weighted Matching in Bipartite Graph [PS82]-Ch 11.1—11.2 • Additional topics: • Reading/Presentation by students Lecture notes modified from those by Lap Chi LAU, CUHK.
Bipartite Matching 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. B A A matching M is a subset of edges so that every vertex has degree at most one in M.
Maximum Matching The bipartite matching problem: Find a matching with the maximum number of edges. A perfect matching is a matching in which every vertex is matched. The perfect matching problem: Is there a perfect matching?
First Try • Greedy method? (add an edge with both endpoints unmatched)
Key Questions • 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?
Existence of Perfect Matching 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. N(S) S
Bound for Maximum Matching What is a good upper bound on the size of a maximum matching? König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Min-max theorem Implies Hall’s theorem.
Algorithmic Idea? Any idea to find a larger matching?
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.
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: A bigger matching an M-augmenting path • Consider • Every vertex in has degree at most 2 • A component in is an even cycle or a path • Since , an M-augmenting path!
Algorithm Key: M is maximum no M-augmenting path How to find efficiently? How to find efficiently?
Finding M-augmenting paths • Orient the edges (edges in M go up, others go down) • An M-augmenting path a directed path between two unmatched vertices
Complexity • At most n iterations • An augmenting path in time by a DFS or a BFS • Total running time
Minimum Vertex Cover 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. Idea: consider why the algorithm got stuck…
Faster Algorithms Observation: Many short and disjoint augmenting paths. Idea: Find augmenting paths simultaneously in one search.
Application of Bipartite Matching Isaac Darek Tom Jerry 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?
Application of Bipartite Matching With Hall’s theorem, now you can determine exactly when a partial chessboard can be filled with dominos.
Application of Bipartite Matching • Latin Square: a nxn square, the goal is to fill the square • with numbers from 1 to n so that: • Each row contains every number from 1 to n. • Each column contains every number from 1 to n.
Application of Bipartite Matching Now suppose you are given a partial Latin Square. Can you always extend it to a Latin Square? With Hall’s theorem, you can prove that the answer is yes.
CS6234: • Matching in Graph • Matching in Bipartite Graph • Matching in General Graphs • Weighted Matching in Bipartite Graph • Additional topics: • Reading/Presentation by students Lecture notes modified from those by Lap Chi LAU, CUHK.
General Matching Given a graph (not necessarily bipartite), find a matching with maximum total weight. unweighted (cardinality) version: a matching with maximum number of edges
Today’s Plan • Min-max theorems [no proofs] • Polynomial time algorithm • Chinese postman [skip] Follow the same structure for bipartite matching.
Characterization of Perfect Matching 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. Tutte’s Theorem [1947]: A graph has a perfect matching if and only if o(G-S) <= |S| for every subset S of V.
Min-Max Theorem König [1931]: In a bipartite graph, the size of a maximum matching is equal to the size of a minimum vertex cover. Tutte-Berge formula [1958]: The size of a maximum matching =
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. Works for general graphs.
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: A bigger matching an M-augmenting path • Consider • Every vertex in has degree at most 2 • A component in is an even cycle or a path • Since , an M-augmenting path!
Algorithm? Key: M is maximum no M-augmenting path How to find efficiently?
Finding Augmenting Path in Bipartite Graphs • Orient the edges (edges in M go up, others go down) • edges in M having positive weights, otherwise negative weights In a bipartite graph, an M-augmenting path corresponds to a directed path.
Finding M-augmenting pathsin General Graphs • Don’t know how to orient the edges so that: an M-augmenting path a directed path between two free vertices …alternating path segment (before & after augmentation): … v1 v2 v3 v4 v5 v6 v7 … Repeated Vertex !!!
No repeated vertices. So? • Just find an alternating path without repeated vertices?! Either we may exclude some possibilities, Or we need to trace the path…
Blossom Note: When performing search for M-augmenting path, we may encounter M-blossom!
Key idea (Edmonds 1965) General matching algorithm Shrink the blossoms!
Key Lemma • (Edmonds) M is a maximum matching in G M/C is a maximum matching in G/C Key: M is maximum no M-augmenting path • an M-augmenting path in G an M/C-augmenting path in G/C
an M/C-augmenting path an M-augmenting path Note: One of the two paths around the blossom will be the correct one.
an M-augmenting path an M/C-augmenting path Note: Many cases to be considered (see [PS82]-Ch10.) Case 0: M-augmenting path p does not “intersect” M-blossom C Case 1: p enters/leaves M-blossom C with matched edge
an M-augmenting path an M/C-augmenting path Case 2: p enters M-blossom C with free edge 2(a): p leaves via matched edge (1st example [in black]) 2(b): p leaves C with free edge (2nd example [in red])
Algorithm Key: M is maximum no M-augmenting path How to find efficiently?
Finding an M-augmenting path • Find an alternatingwalk between two free vertices. • This can be done in linear time by a DFS or a BFS. • Either an M-augmenting path or a blossom can be found. • If a blossom is found, shrink it, and (recursively) find an M/C-augmenting path P in G/C, and then expand P to an M-augmenting path in G.
Complexity • At most n augmentations. • Each augmentation does at most n contractions. • An alternating walk can be found in O(m) time. • Total running time is O(mn2) .
Historical Remarks • In his famous paper “paths, trees, and flowers”, Jack Edmonds: • Introduced the notion of a “good” algorithm. • Edmonds solved weighted general matching, primal dual. • Linear programming description, a breakthrough in polyhedral combinatorics. An O(n3) algorithm by Pape and Conradt, 1980 Ref: [SDK83] Syslo, Deo, Kowalik, Prentice-Hall, 1983 Discrete Optimization Algorithms, Ch 3.7
Proving Min-Max Theorem Tutte-Berge formula [1958]: The size of a maximum matching = Comments by LeongHW: Skip next few slides on mainly combinatorial results… (Anyone wants to do this for reading assignment?)
M-alternating forest Larger forest M-augmenting path a blossom We make progress in any of the above cases.
M-alternating forest Otherwise we find the set in Tutte-Berge formula.
Edmonds-Gallai Decomposition Can be obtained from M-alternating forest. Contains a lot of information about matching.
Chinese Postman Given an undirected graph, a vertex v, a length l(e) on each edge e, find a shortest tour to visit every edge once and come back to v. Visit every edge exactly once if Eulerian. Otherwise, find a minimum weighted perfect matching between odd vertices.
Tutte Matrix • Skew symmetric matrix, a(u,v)=x(e) and a(v,u)=-x(e) • Full rank perfect matching • Randomized algorithm
CS6234: • Matching in Graph • Matching in Bipartite Graph • Matching in General Graphs • Weighted Matching in Bipartite Graph • Additional topics: • Reading/Presentation by students Lecture notes modified from those by Lap Chi LAU, CUHK.