| Title: | Greedy Set Cover |
|---|---|
| Description: | A fast implementation of the greedy algorithm for the set cover problem using 'Rcpp'. |
| Authors: | Matthias Kaeding [aut, cre] |
| Maintainer: | Matthias Kaeding <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-05-18 07:00:35 UTC |
| Source: | https://github.com/cran/RcppGreedySetCover |
Fast greedy set cover algorithm.
greedySetCover(X, data.table = TRUE)greedySetCover(X, data.table = TRUE)
X |
Two-column data.frame in long format: Column 1 identifies the sets, column 2 the elements. |
data.table |
If |
If data.table == TRUE a data.table, keyed by sets and elements.
Else a data.frame, sorted by sets and elements.
Column names are derived from input.
# Create some data. set.seed(333) X <- data.table::rbindlist( lapply( seq_len(1e4L), function(x) list(element=sample.int(n=1e3L,size=sample.int(50L,1L))) ), idcol="set" ) # Elements are integers 1,2,...,1000. # Run set cover res <- greedySetCover(X,FALSE) head(res) # Check if all elements are covered. identical(sort(unique(res$element)),sort(unique(X$element)))# Create some data. set.seed(333) X <- data.table::rbindlist( lapply( seq_len(1e4L), function(x) list(element=sample.int(n=1e3L,size=sample.int(50L,1L))) ), idcol="set" ) # Elements are integers 1,2,...,1000. # Run set cover res <- greedySetCover(X,FALSE) head(res) # Check if all elements are covered. identical(sort(unique(res$element)),sort(unique(X$element)))