swap_an_edge: Swap a single edge

Description Usage Arguments Value Examples

View source: R/bipartite_edge_swap.R

Description

Swap an edge of a bipartite graph while maintaining the partition

Usage

1
swap_an_edge(gr, n1, n2, max_try = 100)

Arguments

gr

tidygraph graph object

n1, n2

vectors that indicate the grouping of the nodes (by index)

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
set.seed(0)
library(tidygraph)
gr <- tidygraph::create_ring(6, directed = FALSE) %>%
    mutate(.idx = 1:n(), name = c("A", "b", "C", "d", "E", "f"))
swaped_gr <- swap_an_edge(gr, c(1,3,5), c(2,4,6))
plot(bind_graphs(gr, swaped_gr))

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