r - 如何将大量 igraph 组合成一个 igraph - R

标签 r list igraph subgraph

我有一个需要过滤的大图。过滤(子图)后,我最终得到一个子图列表。我需要再次将所有这些子图组合成一个图。我不知道如何组合大列表(近百万个子图)

> require(igraph)
> graph <- make_ring(7)  #this is my original graph
> V(graph)$name <- c("A", "B", "C", "D", "E", "F", "G")  #name of vertices
> V(graph)$att1 <- c(1,2,NA,1,2,3,NA)  #some attribute
> selected_vertices <- V(graph)$name[which(V(graph)$att1 == 1)] #let's say i need to subgraph the graph to include only vertices with att1 == 1 (and their first order neighbours)
> subgraph_list <- make_ego_graph(graph, order=1, selected_vertices)  #this creates a list of igraphs but I need one graph containing all the graphs

这失败了:
> subgraph <- induced_subgraph(graph, unlist(subgraph_list ))
Error in as.igraph.vs(graph, vids) : 
  (list) object cannot be coerced to type 'double'

我尝试了其他方法来对图形进行自我子图,但由于它是一个相当大的图形,因此需要很长时间,并且运行良好且相对较快的一个函数是 make_ego_graph,它创建一个列表。

最佳答案

我假设你想要这些图的联合:

do.call(union, subgraph_list)

关于r - 如何将大量 igraph 组合成一个 igraph - R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58552861/

相关文章:

r - unique() 但仅限于连续行

list - 如何删除双括号并仅保留 lisp 中的嵌套列表?

r - 获取 data.frame 的 colclasses 的优雅方法

java - 从 Java 中的 ArrayList 获取唯一值

c++ - 删除分配给列表的内存

r - 在 tidygraph 中过滤

python + igraph "plotting not available"

r - 改进 R 中网络图的布局和分辨率

r - 如何在 R shiny 中动态绘制多个绘图网格

R 用distinct()丢失数据