r - 如何使用 graph.coreness 找到顶点所属的最大 k-core

标签 r graph

我找到了文档 here关于如何使用 graph.coreness

不幸的是,我得到了一个大约有 27000 个条目的数字列表。

我的目的是简单地弄清楚如何找出条目所属的最大 k-core。

我该怎么做?

最佳答案

假设有这张图:

library(igraph)
g <- graph.empty(n=7,directed=FALSE)
g <- add.edges(g, c(1,2,1,3,1,4,3,5,3,4,4,5,2,7,2,6))
g <- set.vertex.attribute(g, name='vert.names',index=V(g),value=LETTERS[V(g)])

graph

你可以通过这种方式得到k核子图:

coreness <- graph.coreness(g) 
maxCoreness <- max(coreness)
# if you just need to know the vertices and not to build the subgraph 
# you can use this variable
verticesHavingMaxCoreness <- which(coreness == maxCoreness) 
kcore <- induced.subgraph(graph=g,vids=verticesHavingMaxCoreness)

plot(kcore, 
     vertex.label=get.vertex.attribute(kcore,name='vert.names',index=V(kcore)))

k-core subgraph

关于r - 如何使用 graph.coreness 找到顶点所属的最大 k-core,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19744335/

相关文章:

r - 用 as.Date 克服 Y2K

r - 当因子分层时,在 RStudio 中使用 ggforest 绘制 Cox PH 模型?

css - R Shiny : relative css size for plotOutput not working

css - 更改图表 Mermaid 中链接上的文本字体

r - 在 R 中填充矩阵的更快方法

r - R 中的条形图图例位置(避免操作重叠)

python - 考虑权重的networkx is_isomorphic

c++ - boost graph adjacency_list,检索节点的父节点

java - 使用 LinkedList 与 HashMap 实现无向图有什么区别?遍历BFS/DFS哪个更好?

r - 识别数据帧每一行中第一个最小值的位置