Committee assignment [00TQ]
Consider the following scenario:
- There are a number of committees; each committee has a desired number of people.
- There is a set of people; each person has (1) a list of committees they are willing to be on, and (2) a maximum total number of committees they are willing to be on.
We can solve this by creating a flow network, as follows:
- There is a vertex for each person, a vertex for each committee, and special source and sink vertices s and t.
- We add an edge from s each each person, with capacity equal to the total number of committees that person is willing to be on.
- From each person, we add edges of capacity 1 to each committee they are willing to be on.
- From each committee, we add an edge to the sink t with capacity equal to the desired size of the committee.
Since valid flows correspond to valid assignments, it is possible to fill all the committees if and only if a maximum flow saturates all the edges going into t.