nocad.placement.greedy_set_cover#

nocad.placement.greedy_set_cover(sets, universe=None, fixed=())[source]#

Greedy (Chvátal) set cover.

Parameters:
setsndarray of bool, shape (n_sets, n_elements)
universendarray of bool, shape (n_elements,), optional

Elements to cover (all by default).

fixedarray_like of int

Sets that are selected beforehand.

Returns:
selectedndarray of int (fixed sets first, then in the order of selection)

Examples

>>> S = np.array([[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 1, 1]], dtype=bool)
>>> greedy_set_cover(S)
array([0, 2])