I have N elements and I want to maximize the number of elements that can be selected given to some constraints of the type “you can take at most 1 element from this subset of the elements”.
Example
I have 10 elements (labeled 1 through 10) with constraints: - You can pick at most 1 element from the set { 1, 5, 7 } - You can pick at most 1 element from the set { 3, 4 } - You can pick at most 1 element from the set { 2, 5, 6, 9 }
An optimal solution is selecting elements { 1, 2, 3, 8, 10 } (I double checked it by writing the exponential solution).
I first though I could reduce it to a maximum matching or flow problem but I failed to do so. Is it a known problem and can it be solved in polynomial time?