0

I was given a problem in a class test. In a library, each member requested for four books and each book was requested by only two members. This information is given in the form of bipartite graph G = ( X + Y , E )

X : Set of all members Y : Set of all books Edge E = set of edges (x,y) where x is a member requested for book y. We have to find the way librarian can give maximum two books to each member such that maximum members are satisfied.

I came out with two approaches:

  1. Introduce two new vertices s(source) and t(destination). Introduce edges from s to all members in X with capacity 2. All edges E has capacity 1 and new edges Y to t has capacity 1. Now apply Max flow algorithm to find maximum matching. The maximum matching is the required solution.
  2. The other way is to follow same algorithm as above by introducing same edges but the capacity of each edge is 1. Now find maximum matching. This matching will give one book to maximum members. Remove the matched books and again apply above algorithm. Again remove the matched books and the members who have got two books and again apply algorithm until no edge between X and Y remain. The achieved solution is the required solution.

Although I got above algorithm but I am not sure which is correct or none is correct. If there is any other algorithm then please suggest here.

Shashwat Kumar
  • 5,159
  • 2
  • 30
  • 66

1 Answers1

0

the first one seems correct. with the second one, you have no guarantee that your first round book assignments will not prevent you from reaching the optimum.

Alix Martin
  • 332
  • 1
  • 5