Skip to contents

Convert communities object to nodegroups list format

Usage

communities2nodegroups(wc, sep = ",", ...)

Arguments

wc

communities object as returned by igraph functions such as cluster_optimal(), cluster_walktrap(), or cluster_leading_eigen().

  • Alternatively, a list object with 'membership' and 'names'.

  • Alternatively, a list object which mimics the output of this function, in which case the input wc is returned as-is.

sep

character string, default ',' (comma), used when cluster_names are defined as a list with vector of names for each cluster. Passed to jamba::cPaste().

...

additional arguments are passed to jamba::cPaste() when relevant.

Value

list of character vectors, where each vector contains names of igraph nodes. When algorithm is defined in the input object, it is included as an attribute of the output list, accessible with attr(out, "algorithm").

When optional value "cluster_names" is present in the communities object, they are used to define the output list names.

Details

Note that this function is "lossy", in that the output list does not contain all the information necessary to reconstitute the input communities object in detail. However, the output list can be converted to a communities object that will be accepted by most igraph related functions that require that object type as an input value.

Alternatively, this function can be used to confirm the input is already appropriate nodegroups list format, by supplying list format upfront.