Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013.

Slides:



Advertisements
Similar presentations
Paths, Trees and Flowers
Advertisements

Connectivity - Menger’s Theorem Graphs & Algorithms Lecture 3.
Every edge is in a red ellipse (the bags). The bags are connected in a tree. The bags an original vertex is part of are connected.
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Algorithms and Networks
Breadth-First Search of Graphs Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
GOLOMB RULERS AND GRACEFUL GRAPHS
Midterm <  70 3.
Yangjun Chen 1 Bipartite Graphs What is a bipartite graph? Properties of bipartite graphs Matching and maximum matching - alternative paths - augmenting.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
1 Dynamic graph connectivity Holm, Lichtenberg, Thorup (98) (based on Henzinger & King (95))
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
What is the next line of the proof? a). Let G be a graph with k vertices. b). Assume the theorem holds for all graphs with k+1 vertices. c). Let G be a.
Matchings Lecture 3: Jan 18. Bipartite matchings revisited Greedy method doesn’t work (add an edge with both endpoints free)
Chapter 26 of CLSR Bipartite Matching By Dr. M. Sakalli, Sources: Levitin and many other CSE, Marmara Univ. May/2009.
Is the following graph Hamiltonian- connected from vertex v? a). Yes b). No c). I have absolutely no idea v.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
CISC220 Fall 2009 James Atlas Nov 13: Graphs, Line Intersections.
D1: Matchings.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
On Channel-Discontinuity-Constraint Routing in Multi-Channel Wireless Infrastructure Networks Abishek Gopalan, Swaminathan Sankararaman 1.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
 Jim has six children.  Chris fights with Bob,Faye, and Eve all the time; Eve fights (besides with Chris) with Al and Di all the time; and Al and Bob.
CSE, IIT KGP Matchings and Factors. CSE, IIT KGP Matchings A matching of size k in a graph G is a set of k pairwise disjoint edges.A matching of size.
Analysis of Algorithms Uri Zwick April 2014 Maximum matching 1 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAA.
10.4 How to Find a Perfect Matching We have a condition for the existence of a perfect matching in a graph that is necessary and sufficient. Does this.
Eric Chang and Rutwik Parikh. Goal: Determine the largest subset of edges in a graph such that no vertex of the graph is touched by more than one edge.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Bipartite Matching. Unweighted Bipartite Matching.
Matching Algorithms and Networks. Algorithms and Networks: Matching2 This lecture Matching: problem statement and applications Bipartite matching Matching.
Assignments and matchings Chapter 12 Presented by Yorai Geffen.
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.
Eulerian Paths and Cycles. What is a Eulerian Path Given an graph. Find a path which uses every edge exactly once. This path is called an Eulerian Path.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Introduction to Graph Theory
Graph Concepts and Algorithms Using LEDA By Caroline Moore and Carmen Frerichs (252a-at and 252a-ao) each graph in the presentation was created using gw_basic_graph_algorithms.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Spanning Tree Definition:A tree T is a spanning tree of a graph G if T is a subgraph of G that contains all of the vertices of G. A graph may have more.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
Maximum Flow - Anil Kishore Graph Theory Basics. Prerequisites What is a Graph Directed, Weighted graphs How to traverse a graph using – Depth First Search.
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
Proof of correctness of Dijkstra’s algorithm: Basically, we need to prove two claims. (1)Let S be the set of vertices for which the shortest path from.
Week 6 - Monday.  What did we talk about last time?  Artificial intelligence  Lab 5.
IOI/ACM ICPC Training 4 June 2005.
Analysis of Algorithms
Chapter 10 Iterative Improvement
12. Graphs and Trees 2 Summary
Paths, Trees and Flowers
Algorithms and Networks
Lecture 16 Bipartite Matching
Lecture 12 Graph Algorithms
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
What is the next line of the proof?
Max Flow min Cut.
Special Graphs: Modeling and Algorithms
Chapter 5. Optimal Matchings
Bipartite Matching and Other Graph Algorithms
Planarity Testing.
Minimum Spanning Tree.
Analysis of Algorithms
Elementary Graph Algorithms
Problem Solving 4.
CSE 373 Data Structures Lecture 16
Flow Networks and Bipartite Matching
Richard Anderson Winter 2009 Lecture 6
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Richard Anderson Lecture 5 Graph Theory
Presentation transcript:

Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin /22/2013

Our Goal Make an algorithm to find the largest cardinality matching (most sets of partners) in ANY graph. Method: Generalize the maximum matching algorithm for bipartite graphs

Review (1/2) Matching: a set of edges without common vertices – Maximum Cardinality Matching: largest # of edges EXPOSED

Review (2/2) An alternating path with respect to M alternates between edges in M and in E-M An augmenting path with respect to M is an alternating path with first and last vertices exposed

Bipartite Graph Algorithm 1 – Start with any matching M (let’s say M = {}) 2 – As long as there exists an augmenting path with respect to M: 3 – Find augmenting path P with respect to M 4 – Augment M along P: M’ = M Δ P 5 – Replace M with the new M’

Bipartite Graph Algorithm 1 – Start with any matching M (let’s say M = {}) 2 – As long as there exists an augmenting path with respect to M: 3 – Find augmenting path P with respect to M 4 – Augment M along P: M’ = M Δ P 5 – Replace M with the new M’ HOW???

Bipartite: Finding an Augmenting Path M = {(1,6),(2,7)} 1 – Direct all edges in the matching from B to A, and all edges not in the matching from A to B 2 – Create a node s that connects to all exposed vertices in set A 3 – Do a Breadth First Search to find an exposed vertex in set B from node s S S

Same A matching is maximum if and only if there are no augmenting paths General Plan: keep looking for augmenting paths to expand the matching Different We can’t add direction to the edges to find augmenting paths We might find “fake” augmenting paths, called FLOWERS

Flowers: Stems & Blossoms EXPOSED

Flowers: Stems & Blossoms EXPOSED

Flowers: Stems & Blossoms EXPOSED Blossom Stem

Flowers: Stems & Blossoms EXPOSED Blossom Stem Even, alternating path from an exposed vertex to the blossom Odd, alternating cycle with two edges adjacent to the stem and not in M

Revised Algorithm 1 – Start with any matching M (let’s say M = {}) 2 – Find a flower, augmenting path or neither: 3 – If neither: We’re done! 4 – If augmenting path: augment to M’ = M Δ P 5 – If flower: find a larger matching or decide that M is maximum…

Theorem: M is maximum in G if and only if M-B is maximum in G-B 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B ß ß 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B ß ß 1- Flip the stem -The matching is still the same size -The blossom has an exposed vertex 2- Shrink the blossom to one single vertex -All vertices in B combine into ß -Edges into any vertex in B go into ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Theorem: M is maximum in G if and only if M-B is maximum in G-B ß ß 3- The matching M-B in graph G-B is |B-1|/2 smaller than matching M in G

Increasing a Matching from a Flower ß ß Augment new Graph

ß ß Add back in the blossom with extra edges from the new matching Increasing a Matching from a Flower

Revised Algorithm 1 – Start with any matching M (let’s say M = {}) 2 – Find a flower, augmenting path or neither: 3 – If neither: We’re done! 4 – If augmenting path: augment to M’ = M Δ P 5 – If flower: (recursively…) a. Flip the stem b. Shrink the blossom to a single vertex c. Increase M or decide that it is Maximum

Revised Algorithm 1 – Start with any matching M (let’s say M = {}) 2 – Find a flower, augmenting path or neither: 3 – If neither: We’re done! 4 – If augmenting path: augment to M’ = M Δ P 5 – If flower: (recursively…) a. Flip the stem b. Shrink the blossom to a single vertex c. Increase M or decide that it is Maximum HOW???

Finding Flowers and Augmenting Paths A B C D E F G H J

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests A B C D E F G H J 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower

Creating Alternating Forests 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower A B C D E F G H J

Creating Alternating Forests 1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one 2. Add edges (u, v) from u in the forest to v 3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE 4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path 5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower A B C D E F G H J

Questions?