I found the documentation here on how to use graph.coreness
.
我在这里找到了如何使用图形的文档。
Unfortunately I get back a list of numbers which was about 27000 entries long.
不幸的是,我得到了一份大约有27000个条目的数字列表。
My purpose is to simply figure out how to find out the largest k-core the entries belong to.
我的目的是简单地找出如何找出条目所属的最大k-core。
How do I do that?
我该怎么做呢?
2 个解决方案
#1
4
Supposing to have this graph :
假设有这个图:
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)])
You can get the k-core subgraph in this way :
你可以用这种方法得到k-core子图:
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)))
#2
1
I figured this out using this link
我用这个链接算出来了。
https://*.com/a/3692710/80353
Basically I do this.
基本上我这样做。
cores = graph.coreness(as.undirected(g))
head(sort(cores, decreasing=TRUE), 3)
This will give me the 3 highest k-core values in the vector.
这将给出向量中3个最高的k-core值。
#1
4
Supposing to have this graph :
假设有这个图:
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)])
You can get the k-core subgraph in this way :
你可以用这种方法得到k-core子图:
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)))
#2
1
I figured this out using this link
我用这个链接算出来了。
https://*.com/a/3692710/80353
Basically I do this.
基本上我这样做。
cores = graph.coreness(as.undirected(g))
head(sort(cores, decreasing=TRUE), 3)
This will give me the 3 highest k-core values in the vector.
这将给出向量中3个最高的k-core值。