curveball | R Documentation |
curveball
randomizes an incidence matrix or bipartite graph, preserving the row and column sums
curveball(M, trades = 5 * nrow(M), class = NULL)
M |
a binary matrix of class |
trades |
integer: number of trades; the default is 5 * nrow(M) (approx. mixing time) |
class |
string: Return object as |
Strona et al. (2014) provided an initial implementation of the Curveball algorithm in R. curveball()
is a modified R
implementation that is slightly more efficient. For an even more efficient algorithm, see backbone::fastball()
.
An incidence matrix of class matrix
or Matrix
, or a bipartite graph of class igraph.
Strona, Giovanni, Domenico Nappo, Francesco Boccacci, Simone Fattorini, and Jesus San-Miguel-Ayanz. 2014. A Fast and Unbiased Procedure to Randomize Ecological Binary Matrices with Fixed Row and Column Totals. Nature Communications, 5, 4114. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/ncomms5114")}
Godard, Karl and Neal, Zachary P. 2022. fastball: A fast algorithm to sample bipartite graphs with fixed degree sequences. Journal of Complex Networks, 10, cnac049. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/comnet/cnac049")}
Neal, Z. P. 2022. incidentally: An R package to generate incidence matrices and bipartite graphs. CRAN \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/CRAN.package.incidentally")}
M <- incidence.from.probability(5,5,.5) #A matrix
Mrand <- curveball(M) #Random matrix with same row/col sums
all.equal(rowSums(M), rowSums(curveball(M)))
all.equal(colSums(M), colSums(curveball(M)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.