我有一个庞大的图表需要进行筛选。经过筛选(子图化)后,我得到一系列子图清单。我需要将这些子图合并为一个原始图表。我不知道如何合并这个包含将近一百万子图的庞大清单。
> 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,它可以创建一个列表。
Reduce("+", subgraph_list)
? - Roland