merge_communities: Merge communities in a network

Description Usage Arguments Details Value

View source: R/merge.R

Description

Aggregate nodes in given communities into 'super-nodes' that represent those communities, and combine any associated inter- or intra-community links.

Usage

1
2
3
4
5
6
7
merge_communities(x, communities)

## Default S3 method:
merge_communities(x, communities)

## S3 method for class 'igraph'
merge_communities(x, communities)

Arguments

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.

Details

Any matrix-like x argument will be coerced to a dgCMatrix.

Value

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.


Selbosh/scrooge documentation built on May 5, 2019, 8 p.m.