swap_an_edge2: Swap a single edge (method 2)

Description Usage Arguments Value Examples

View source: R/bipartite_edge_swap2.R

Description

Swap an edge of a bipartite graph while maintaining the partition

Usage

1
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

1
2
3
4
5
6
7
8
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)))

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