r - 如何将大量 igraph 组合成一个 igraph - R
问题描述
我有一个需要过滤的大图。过滤(子图)后,我最终得到一个子图列表。我需要再次将所有这些子图组合成一个图。我不知道如何组合大列表(近一百万个子图)
> 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)
推荐阅读
- powerbi - Power BI 服务管理员是否应该查看其他用户创建的所有工作区?
- python - 如何在每个数据集的 for 循环期间创建数据框并防止创建新列和附加行
- flutter - pumpAndSettle 超时 Mockito Flutter
- html5-video - 在 html5 中播放 hls 的正确 url
- entity-framework-core - Asp.Net Core HealthChecks 并发实体框架 DbContext 错误
- xcode - 使用 CleanMyMac 后,我的 xcode 变慢了
- pandas - 获取每行多列的平均值,不包括带有熊猫的特定列
- python - 类“list”的未解析属性引用“find_all”
- r - 错误:pandoc 文档转换失败,错误 4
- go - 添加 goroutine 并发以提高代码效率