如何将函数应用于图形/网络中的每个连接组件?
我有一个大型 igraph 对象,有 70,000 多个顶点(节点)和 200,000 多个边(连接)。我想计算一些中心性度量,但网络太大。我认为一个好的解决方法是将我的网络分解为连接的组件(即使是最大的组件也不会太大)。
我正在考虑使用 igraph 函数 clusters 或相关方法。然后我可以计算集群上的 alpha.centrality() 和 bonpow() 吗?然后将结果合并回原始 igraph 对象? (或具有所有顶点的数据框)
我不确定最好的方法,我真的很想听听人们的任何想法。非常感谢:)
I have a large igraph object 70,000+ vertices (nodes) and 200,000+ edges (connections). I'd like to calculate some measures of centrality but the network is too big. I thought a good work around would be to break my network into connected components (even the largest isn't too big).
I was thinking about using the igraph function clusters or related methods. Could I then calculate alpha.centrality() and bonpow() on the clusters? and then merge the results back into the original igraph object? (or a dataframe with all vertices)
I'm not sure of the best approach and I'd be really interested to hear any ideas people have. Many thanks :)
您可以使用igraph中的
decompose.graph
函数来获取连接组件的列表,然后使用lapply
来运行您的函数(alpha.centrality
> 或bonpow
)在每个组件上。运行decompose.graph
后,您可能需要释放原始图以重新声明一些内存。You can use the
decompose.graph
function in igraph to obtain a list of the connected components, then uselapply
to run your function (alpha.centrality
orbonpow
) on each of the components. After having rundecompose.graph
, you may want to deallocate your original graph to re-claim some memory.