Skip to main content

hitting_set

Function hitting_set 

Source
pub fn hitting_set(universe: usize, sets: &[Vec<usize>]) -> Vec<usize>
Expand description

Greedy hitting set: find a small set H ⊆ {0..universe-1} such that every input set contains at least one element of H.

Equivalent to set cover on the dual hypergraph. Greedily picks the element that “hits” the most unhit sets.

Returns the hitting set as a sorted list of element indices.