R/only_single_graphs.R

Defines functions only.single.graphs

Documented in only.single.graphs

#' Generates the solution when only singletons are yielded
#'
#' @param total_nodos Total number of nodes in data matrix.
#' @param nodos_singletons Nodes list with cluster singletons.
#' @return An object of class "igraph" as a network representing the clustering solution.
#' @keywords internal
#' @export
only.single.graphs <- function(total_nodos, nodos_singletons) {

  clusteres_unidos <- igraph::graph(edges = NULL, n = NULL, directed = FALSE)
  clusteres_unidos <- clusteres_unidos + igraph::vertices(total_nodos)

  if (length(nodos_singletons) > 0) {
    single <- as.character(unlist(unique(nodos_singletons)))
    clusteres_unidos <- clusteres_unidos + igraph::path(single)
  }

  return(clusteres_unidos)
}

Try the mstknnclust package in your browser

Any scripts or data that you put into this service are public.

mstknnclust documentation built on May 13, 2026, 9:06 a.m.