R/exact-cluster-editing.R

Defines functions balanced_cluster_editing

#' Solve exact equal-sized cluster editing
#'
#' @param data A N x N distance matrix or N x M features table.
#' @param K How many clusters are to be created.
#' @param solver "glpk" or "symphony"
#'
#' @return A vector representing the clustering.
#'
#' @noRd
#' 
#'
balanced_cluster_editing <- function(data, K, solver) {
  if (!is_distance_matrix(data)) {
    data <- as.matrix(dist(data))
  }
  ilp <- anticlustering_ilp(data, K)
  solution <- solve_ilp(ilp, "min", solver)
  ilp_to_groups(solution, nrow(data))
}
m-Py/anticlust documentation built on April 13, 2025, 11:17 p.m.