r - 断开连接图的巨型组件本身断开连接的警告消息
问题描述
我在这里有点困惑,我使用以下代码提取了断开连接图的巨大组件。
function(graph) {
cl <- clusters(graph)
induced.subgraph(graph, which(cl$membership == which.max(cl$csize)))
}
但是在 RStudio 中运行这样的代码会给我频繁的错误,例如
is_connected(ngo.giant)
[1] TRUE
centr_clo(ngo.giant)$centralization
[1] 0.003214897
Warning message:
In centr_clo(ngo.giant) :
At centrality.c:2784 :closeness centrality is not well-defined for disconnected graphs
temp<-centr_eigen(ngo.giant,directed=T)
Warning message:
In centr_eigen(ngo.giant, directed = T) :
At centrality.c:344 :graph is directed and acyclic; eigenvector centralities will be zeros
发生这种情况有原因吗?抱歉,如果此代码太模糊
解决方案
我刚刚收到该警告,我注意到这是由于我的图表是定向的,因此某些路径只能沿一个方向行走,而某些节点与另一个节点“断开”。
test <- data.frame(source=c('a', 'a'), target=c('b', 'c'), stringsAsFactors=FALSE)
g <- igraph::graph_from_data_frame(test, directed=TRUE)
igraph::closeness(g)
a b c
0.5000000 0.1666667 0.1666667
Warning message:
In igraph::closeness(g) :
At centrality.c:2784 :closeness centrality is not well-defined for disconnected graphs
同样,如果您使用 in 中的参数mehtod='all'
,closeness
您的图将被视为无向图。
推荐阅读
- java - 以编程方式设置 lottie 动画视图的宽度和高度
- uitabbar - 是否可以在 tvOS 的 uitabbaritems 上为聚焦和选定状态使用不同的颜色?
- python - 而不是使用 drop_first=True,我如何在 pandas 中设置虚拟编码的参考级别
- php - 以编程方式增加唯一列的计数
- java - 二维数组中列的总和,Java
- android - 最新的 Samsung Pass 库?
- version-control - 在后端和前端之间管理版本的最佳实践
- mongodb - 按需环境的 MongoDB 设置
- jenkins - Jenkins 文件在失败时发送电子邮件
- linux - 如何从linux中的特定文件夹中删除文件?