I have several lists, that you can consider as rows of integers. For example :
[1 3 5]
[3 7]
[3 5 7]
[1 5 9]
[3 9]
[1 7]
[5 9 11]
I wish to find the smallest possible set of integers represented on these rows, so that :
- each row has at least one of the selected integers,
- in case of cardinality ties, select the set having the highest sum.
In my example, I believe the result should be [5 7 9] (preferred to [3 5 7] or [1 3 11] or ... many possibilities).
The second part is trivial (selecting highest sum), but the generation of all minimal subsets in cardinality seems to be hard.
Do you know a good way to achieve this ?
Edit
Size of data is growing slowly with iterations, but I need exact matches.