R/utils.R

Defines functions delete_isolates biggest_component

Documented in biggest_component delete_isolates

#' @title helper function
#' @description small functions to deal with typical network problems
#'
#' @param g igraph object
#' @name helpers
#' @return igraph object
#' @author David Schoch
NULL

#' @rdname helpers
#' @export
biggest_component <- function(g) {
    comps <- igraph::components(g, mode = "weak")
    igraph::induced_subgraph(g, which(comps$membership == which.max(comps$csize)))
}

#' @rdname helpers
#' @export
delete_isolates <- function(g) {
    igraph::delete_vertices(g, which(igraph::degree(g) == 0))
}
schochastics/netUtils documentation built on Oct. 17, 2024, 10:45 a.m.