0% found this document useful (0 votes)
85 views

CMSC 451: Maximum Bipartite Matching: Slides By: Carl Kingsford

This document discusses how to solve the maximum bipartite matching problem by reducing it to a network flow problem. It describes how to construct a flow network from a bipartite graph that models the matching problem, such that the maximum flow in the new network corresponds to the maximum matching in the original graph. Solving the resulting network flow problem takes O(mn) time, thus solving maximum bipartite matching takes O(mn) time.

Uploaded by

Mohamed Kobeissi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

CMSC 451: Maximum Bipartite Matching: Slides By: Carl Kingsford

This document discusses how to solve the maximum bipartite matching problem by reducing it to a network flow problem. It describes how to construct a flow network from a bipartite graph that models the matching problem, such that the maximum flow in the new network corresponds to the maximum matching in the original graph. Solving the resulting network flow problem takes O(mn) time, thus solving maximum bipartite matching takes O(mn) time.

Uploaded by

Mohamed Kobeissi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

CMSC 451: Maximum Bipartite Matching

Slides By: Carl Kingsford

Department of Computer Science University of Maryland, College Park

Based on Section 7.5 of Algorithm Design by Kleinberg & Tardos.

Network Flows

10 20 s 10 10

u 10 20 15 v 5 5

x 20

15

30

30 10 w 5

The network ow problem is itself interesting. But even more interesting is how you can use it to solve many problems that dont involve ows or even networks.

Bipartite Graphs
People Tasks

Suppose we have a set of

people L and set of jobs R .


Each person can do only
Pe rso nu can do

tas

kx

some of the jobs.


Can model this as a

bipartite graph

Bipartite Matching
People Tasks 1

A matching gives an

assignment of people to tasks.


Want to get as many tasks

done as possible.
c 3

So, want a maximum

matching: one that contains as many edges as possible.


(This one is not maximum.)

Maximum Bipartite Matching

Maximum Bipartite Matching Given a bipartite graph G = (A B , E ), nd an S A B that is a matching and is as large as possible.

Notes:
Were given A and B so we dont have to nd them. S is a perfect matching if every vertex is matched. Maximum is not the same as maximal: greedy will get to

maximal.

Reduce

Given an instance of

bipartite matching,
Create an instance of

Instance of Maximum Bipartite Matching

network ow.
Where the solution to the

transform, aka reduce

network ow problem can easily be used to nd the solution to the bipartite matching.

Instance of Network Flow

Reducing Bipartite Matching to Net Flow


People a Tasks 1

Reducing Bipartite Matching to Net Flow


People a Tasks 1

Reducing Bipartite Matching to Net Flow


People a Tasks 1

Reducing Bipartite Matching to Net Flow


People a 1 1 1 1 s 1 1 1 d c b 1 1 1 1 1 e 1 5 4 3 1 1 1 2 1 t 1 1 Tasks 1

Using Net Flow to Solve Bipartite Matching

To Recap:
1

Given bipartite graph G = (A B , E ), direct the edges from A to B . Add new vertices s and t . Add an edge from s to every vertex in A. Add an edge from every vertex in B to t . Make all the capacities 1. Solve maximum network ow problem on this new graph G .

2 3 4 5 6

The edges used in the maximum network ow will correspond to the largest possible matching!

Analysis, Notes

Because the capacities are integers, our ow will be integral. Because the capacities are all 1, we will either: use an edge completely (sending 1 unit of ow) or not use an edge at all.

Let M be the set of edges going from A to B that we

use.
We will show that 1 M is a matching 2 M is the largest possible matching

M is a matching
We can choose at most one edge leaving any node in A. We can choose at most one edge entering any node in B .
People a 1 1 1 1 s 1 1 1 d c b 1 1 1 1 1 e 1 5 4 3 1 1 1 2 1 t 1 1 Tasks 1

If we chose more than 1, we couldnt have balanced ow.

Correspondence between ows and matchings


If there is a matching

of k edges, there is a ow f of value k .

If there is a ow f of

B A
e 5

value k , there is a matching with k edges.

v(f) = fout(A) - fin(A)

Correspondence between ows and matchings


If there is a matching

of k edges, there is a ow f of value k .


f has 1 unit of

ow across each of the k edges.


1 unit leaves &
s

enters each node (except s , t ) If there is a ow f of

B A
e 5

value k , there is a matching with k edges.

v(f) = fout(A) - fin(A)

M is as large as possible

We nd the maximum ow f (say with k edges).

This corresponds to a matching M of k edges.

If there were a matching with > k edges, we would have found

a ow with value > k , contradicting that f was maximum.

Hence, M is maximum.

Running Time
How long does it take to solve the network ow problem on

G?
The running time of Ford-Fulkerson is O (m C ) where m is

the number of edges, and C =


C = |A| = n.

e leaving s ce .

The number of edges in G is equal to number of edges in G

(m) plus 2n.


So, running time is O ((m + 2n)n) = (mn + n2 ) = O (mn)

Theorem We can nd maximum bipartite matching in O (mn) time.

Summary: Bipartite Matching

Fold-Fulkerson can nd a

Instance of Maximum Bipartite Matching

maximum matching in a bipartite graph in O (mn) time.


We do this by reducing the

transform, aka reduce

problem of maximum bipartite matching to network ow.

Instance of Network Flow

You might also like