Description Usage Arguments Value Examples
View source: R/bipartite_edge_swap2.R
Swap an edge of a bipartite graph while maintaining the partition
1 | swap_an_edge2(el, N, max_try = 100)
|
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" |
a tidygraph graph object with two edges swapped
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)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.