bipartite_edge_swap: Swap edges of a bipartite graph

Description Usage Arguments Value Examples

View source: R/bipartite_edge_swap.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_swap(gr, Q = 20, N = Q * igraph::ecount(gr))

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
set.seed(0)
bgr <- tidygraph::create_ring(6, directed = FALSE)
bgr <- tidygraph::mutate(bgr, type = rep(c(TRUE, FALSE), 3))
print(bgr)
print(bipartite_edge_swap(bgr, 10))

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