Sync igraph nodes and communities

sync_igraph_communities(g, wc, verbose = TRUE, ...)

Arguments

g

igraph object

wc

communities object, or list in form of nodegroups, which is a list of character vectors that contain igraph node names.

verbose

logical indicating whether to print verbose output.

...

additional arguments are passed to nodegroups2communities() only when input wc is supplied in list nodegroups format.

Value

list with two elements:

  • "g" - the igraph object after subsetting to match node names shared with wc, as necessary.

  • "wc' - the communities object after subsetting to match node names shared with g, as necessary. When input wc is in list nodegroups format, that same format is returned.

Details

This function ensures that igraph nodes and corresponding community clusters are synchronized for proper downstream use. In particular, when using a subgraph, or when communities only assign a subset of nodes to clusters, this function ensures the two objects are in sync, the same order, and with the same nodes.