bipartite_edge_swap2: Swap edges of a bipartite graph (method 2)

Description Usage Arguments Value Examples

View source: R/bipartite_edge_swap2.R

Description

Run the edge swapping algorithm from Milo et al. (2003) on a bipartite graph while maintaining the separation of the nodes in two groups.

Usage

1
bipartite_edge_swap2(gr, Q = 20, N = igraph::ecount(gr) * Q)

Arguments

gr

a tidygraph object with a node attribute called type that holds boolean values (i.e. either TRUE or FALSE)

Q

number of permutations you are conducting; default is 20

N

the number of edge swaps; default is Q \times |E(G)|

Value

the graph with N random edge swaps with constrained marginals

Examples

1
2
3
4
5
6
7
8
9
set.seed(0)
bgr <- tidygraph::create_ring(6, directed = FALSE)
bgr <- tidygraph::mutate(
    bgr,
    type = rep(c(TRUE, FALSE), 3),
    name = LETTERS[1:6]
)
print(bgr)
print(bipartite_edge_swap2(bgr, 10))

jhrcook/wext documentation built on May 17, 2021, 1:19 a.m.