finding a maximum matching in non-bipartite graphs alicia thilani singham goodwin 18.304 3/22/2013
TRANSCRIPT
![Page 1: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/1.jpg)
Finding a Maximum Matchingin Non-Bipartite Graphs
Alicia Thilani Singham Goodwin18.304 • 3/22/2013
![Page 2: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/2.jpg)
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
![Page 3: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/3.jpg)
Review (1/2)
• Matching: a set of edges without common vertices
– Maximum Cardinality Matching: largest # of edges
EXPOSED
![Page 4: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/4.jpg)
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
![Page 5: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/5.jpg)
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
M4 – Augment M along P: M’ = M Δ P5 – Replace M with the new M’
![Page 6: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/6.jpg)
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 M4 – Augment M along P: M’ = M Δ P5 – Replace M with the new M’HOW???
![Page 7: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/7.jpg)
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
![Page 8: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/8.jpg)
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
![Page 9: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/9.jpg)
Flowers: Stems & Blossoms
EXPOSED
![Page 10: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/10.jpg)
Flowers: Stems & Blossoms
EXPOSED
![Page 11: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/11.jpg)
Flowers: Stems & Blossoms
EXPOSED
BlossomStem
![Page 12: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/12.jpg)
Flowers: Stems & Blossoms
EXPOSED
BlossomStem
Even, alternating path from an exposed vertex to the blossom
Odd, alternating cycle with two edges adjacent to the stem and not in M
![Page 13: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/13.jpg)
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 Δ P5 – If flower: find a larger matching or
decide that M is maximum…
![Page 14: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/14.jpg)
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
![Page 15: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/15.jpg)
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
![Page 16: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/16.jpg)
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
![Page 17: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/17.jpg)
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
![Page 18: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/18.jpg)
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
![Page 19: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/19.jpg)
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
![Page 20: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/20.jpg)
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
![Page 21: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/21.jpg)
Increasing a Matching from a Flower
ß
Augment new Graph
![Page 22: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/22.jpg)
ßAdd back in the blossom
with extra edges from the new matching
Increasing a Matching from a Flower
![Page 23: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/23.jpg)
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 Δ P5 – If flower: (recursively…)
a. Flip the stemb. Shrink the blossom to a single vertexc. Increase M or decide that it is
Maximum
![Page 24: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/24.jpg)
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 Δ P5 – If flower: (recursively…)
a. Flip the stemb. Shrink the blossom to a single vertexc. Increase M or decide that it is
Maximum
HOW???
![Page 25: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/25.jpg)
Finding Flowers and Augmenting Paths
A B
C
D
E
F
G
H
J
![Page 26: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/26.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 27: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/27.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 28: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/28.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 29: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/29.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 30: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/30.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 31: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/31.jpg)
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 one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. If an edge (u, v) already has v labelled SQUARE and v belongs to the same alternating tree, then we have found a flower
![Page 32: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/32.jpg)
Creating Alternating Forests1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. 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
![Page 33: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/33.jpg)
Creating Alternating Forests1. Label all exposed vertices as SQUARE, start a new tree in our alternating forest for each one2. Add edges (u, v) from u in the forest to v3. If an edge (u, v) has v unlabelled, label it TRIANGLE. Label its “mate” (across an edge in the matching) as a SQUARE4. If an edge (u, v) already has v labelled SQUARE and v belongs to a different alternating tree, then we have an augmenting path5. 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
![Page 34: Finding a Maximum Matching in Non-Bipartite Graphs Alicia Thilani Singham Goodwin 18.304 3/22/2013](https://reader035.vdocuments.us/reader035/viewer/2022062308/56649d145503460f949e8986/html5/thumbnails/34.jpg)
Questions?