I have a regular graph and wanna delete randomly edge from graph. How to select edges randomly till I can delete?
library(igraph)
g = sample_k_regular(10,3)
You can use the sample(x,n)
function in base R along with delete_edges
from igraph
.
For example, if you want to delete 5 edges:
library(igraph)
g = sample_k_regular(10,3)
g1 <- delete_edges(g,sample(E(g),5))
E(g)
gets a list of edges that sample randomly samples from.