Aggregate nodes in given communities into 'super-nodes' that represent those communities, and combine any associated inter- or intra-community links.
merge_communities(x, communities) # S3 method for default merge_communities(x, communities) # S3 method for igraph merge_communities(x, communities)
x | a matrix of citations (from columns to rows) or an igraph object |
---|---|
communities | A numeric vector that specifies the mapping, or a communities object. Its elements correspond to the vertices, and for each element the id in the new graph is given. |
A sparse matrix, representing a contingency table of edges from communities to nodes.
While it would be nice to return an igraph object when given an x
of that class,
the process of aggregating the 'from' nodes while preserving 'to' nodes would mean coercing
the directed graph to an undirected bipartite graph, then contracting vertices in one mode
and not the other. This may be difficult to implement, so for the time-being we simply convert
igraph objects to weighted adjacency matrices and then pass to merge_communities.default
.
Any matrix-like x
argument will be coerced to a dgCMatrix
.