Swap an edge of a bipartite graph while maintaining the partition

swap_an_edge2(el, N, max_try = 100)

Arguments

el

edge list composed of a list of two vectors, one for each group of the bipartite graph

N

the number of edge swaps

max_try

Number of times to try to find two edges to swap. If no edges are found, the program will crash with the message "Unable to swap edges"

Value

a tidygraph graph object with two edges swapped

Examples

set.seed(0) suppressPackageStartupMessages(library(tidygraph)) gr <- create_ring(6, directed = FALSE) %>% mutate(type = rep(c(TRUE, FALSE), 3), name = LETTERS[1:6]) el <- to_bipartite_edgelist(gr) swaped_el <- swap_an_edge2(el, 10) plot(bind_graphs(gr, edgelist_to_bipartite_graph(swaped_el)))