Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个常规图,想从图中随机删除边。如何随机选择边缘直到我可以删除?
library(igraph) g = sample_k_regular(10,3)
您可以将sample(x,n)基础 R 中的函数与delete_edgesfrom一起使用igraph。
sample(x,n)
delete_edges
igraph
例如,如果要删除 5 条边:
library(igraph) g = sample_k_regular(10,3) g1 <- delete_edges(g,sample(E(g),5))
E(g)获取从中随机采样的边列表。
E(g)