From e3b69b291e6159853bdf8fce2ab0c5773356925c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szabolcs=20Horva=CC=81t?= Date: Mon, 5 Feb 2024 22:37:37 +0000 Subject: [PATCH] docs: document 'dsatur' heuristic for greedy_vertex_coloring() --- R/coloring.R | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/R/coloring.R b/R/coloring.R index 3544de1de20..55d0b7bf393 100644 --- a/R/coloring.R +++ b/R/coloring.R @@ -3,19 +3,23 @@ #' `greedy_vertex_coloring()` finds a coloring for the vertices of a graph #' based on a simple greedy algorithm. #' -#' The goal of vertex coloring is to assign a "color" (i.e. a positive integer -#' index) to each vertex of the graph such that neighboring vertices never have -#' the same color. This function solves the problem by considering the vertices -#' one by one according to a heuristic, always choosing the smallest color index -#' that differs from that of already colored neighbors. The coloring obtained -#' this way is not necessarily minimal but it can be calculated in linear time. +#' The goal of vertex coloring is to assign a "color" (represented as a positive +#' integer) to each vertex of the graph such that neighboring vertices never +#' have the same color. This function solves the problem by considering the +#' vertices one by one according to a heuristic, always choosing the smallest +#' color that differs from that of already colored neighbors. The coloring +#' obtained this way is not necessarily minimum but it can be calculated in +#' linear time. #' -#' @param graph The graph object to color +#' @param graph The graph object to color. #' @param heuristic The selection heuristic for the next vertex to consider. -#' Currently only one heuristic is supported: \dQuote{colored_neighbors} -#' selects the vertex with the largest number of already colored neighbors. +#' Possible values are: \dQuote{colored_neighbors} selects the vertex with the +#' largest number of already colored neighbors. \dQuote{dsatur} selects the +#' vertex with the largest number of unique colors in its neighborhood, i.e. +#' its "saturation degree"; when there are several maximum saturation degree +#' vertices, the one with the most uncolored neighbors will be selected. #' @return A numeric vector where item `i` contains the color index -#' associated to vertex `i` +#' associated to vertex `i`. #' #' @family coloring #' @export