Learn R Programming

backbone (version 2.0.3)

bipartite.add.blocks: Adds a block structure to a bipartite network

Description

bipartite.add.blocks rewires a bipartite graph B to have a block structure such that edges are located within-block with density probability, while preserving both degree distributions.

Usage

bipartite.add.blocks(B, blocks = 2, density = 0.5, max.tries = 1e+05)

Arguments

B

A bipartite network object of class "matrix", "sparseMatrix", igraph, matrix or dataframe edgelist, or network

blocks

integer: number of blocks to add (between 2 and 26)

density

numeric: desired within-block density

max.tries

numeric: number of ineligible re-wiring attempts before giving up

Details

Each row node and each column node are randomly assigned to one of blocks number of groups. Then degree-preserving checkerboard swaps are performed that increase the within-block density, until density is achieved. Eligible swaps are identified randomly, so the re-wiring can be slow when B is large. The process can get stuck when no eligible swaps remain but the target density has not been achieved; if this happens, increase max.tries to keep looking for eligible swaps or reduce the target density.

Examples

Run this code
# NOT RUN {
B <- bipartite.from.probability(R = 100, C = 100, P = .5)
B <- bipartite.add.blocks(B, blocks = 2, density = .7)
# }

Run the code above in your browser using DataLab