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