Finding the smallest 'Spanning Set'

62 Views Asked by At

Assume I have two sets of elements $A = \{a_1, a_2, \dotsc , a_n\}$ and $B = \{b_1, b_2, \dotsc , b_m\}$.

There is a relationship defined between the two sets such that each element of $A$ maps onto $1$ or more elements of $b$.

For example:

$a_1 \to \{b_2, b_3, b_9\}$

$a_2 \to \{b_7\}$

$a_3 \to \{b_2, b_4, b_9\}$

etc.

Every element in B is mapped onto by at least $1$ element in A.

The problem is to find the smallest subset of $A$ (say $A'$) such that the union of the mappings of all the elements in $A'$ onto $B$ completely covers $B$. In other words, for any element $b$ in $B$, there is an element $a'$ in $A'$ such that $a' \to b$.

One can imagine $A$ to be a list of players and $B$ to be list of matches, then one has to find the smallest set of players such that at least one of them has taken part in every match $B$.

Does anyone know if there is an efficient algorithm for doing this? Does this problem have a name?

Thanks in advance!