I was reading http://www.geeksforgeeks.org/maximum-bipartite-matching/ and http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm and am having trouble understanding. It seems the example is under the assumptions that each job can only accept 1 person and each person wants 1 job. I was wondering how the algorithm/code would change if for example, the v set had capacity > 1 (can hire multiple people for that job) and the u set > 1 (each person wants more than 1 job)?
Maximum bipartite matching solutionSuch a problem can be solved very effectively by the Ford Fulkerson algorithm, which connects and disconnects all possible edges in the graph till the maximum match number is found, such as the highest edge count.
A matching in a Bipartite Graph is a set of the edges chosen in such a way that no two edges share an endpoint. A maximum matching is a matching of maximum size (maximum number of edges). In a maximum matching, if any edge is added to it, it is no longer a matching.
For a bipartite graph G = (V, E) maximum matching are matching whose cardinalities are maximum among all matchings. Existing enumerating algorithm of maximum matching has time complexity is O(|V |) per matching. Ford- Fulkerson method finds the maximum matching on a bipartite graph with O(VE) time.
To allow jobs to have more than one person assigned to them, you'd only modify edge capacities from Jobs
to Terminal
(Similar to how Niklas B. described in his comment, but not exactly.)
Like this:
The capacities of 1 from the Source
to the People
, and 1 from People
to Jobs
guarantees that a person will only ever be selected for one job (because the maximum flow that they can contribute overall is 1). However, the capacities > 1
from Jobs
to Terminal
allows that more than one person can be assigned to that job.
If a person can perform also more than 1 job, then the max flow from Source
to Person
increases by that amount:
Where i
, j
, k
, and x
are stand-ins for integers with values >= 1
The key thing to remember here is that flow capacities to the left of People
dictate how many jobs they may take, and the flow capacities to the right of Jobs
dictate how many people may be assigned that job. The capacities in the middle should not change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With