我在R中使用iGraph来计算一组10个节点的k核。其中8个节点连接,度数为5或更大,另外两个节点的度数为3。
根据我对k核的理解,不应该连接8个节点,并且至少有5个节点都在k核中,值为5吗?然而,这8个中的两个被赋予k核值4和3。
请参阅下面的可重现图表:
el = matrix(c("Ns-1","Ns-1","Ns-1","Ns-1","Ns-1","Ns-1","Ns-1","Ns-1","Ns-14","Ns-14","Ns-15","Ns-15","Ns-15","Ns-17","Ns-17","Ns-17","Ns-17","Ns-2","Ns-2","Ns-2","Ns-2","Ns-4","Ns-4","Ns-4","Ns-5","Ns-5","Ns-5","TAMU-7","Ns-14","Ns-15","Ns-17","Ns-2","Ns-4","Ns-5","TAMU-7","TAMU-8","Ns-15","Ns-17","Ns-17","Ns-4","Ns-18","Ns-2","Ns-4","Ns-5","Ns-18","Ns-4","Ns-5","TAMU-7","TAMU-8","Ns-5","TAMU-7","TAMU-8","TAMU-7","TAMU-8","Ns-18","TAMU-8"),nrow=28,ncol=2)
graph = graph.edgelist(el[,1:2],directed=F)
l <- layout.kamada.kawai(graph)
V(graph)$x <- l[,1]
V(graph)$y <- l[,2]
V(graph)$kCore = graph.coreness(graph)
V(graph)$degree = degree(graph)
layout(matrix(c(1,2), 1, 2))
plot(graph,
main="Degree",
vertex.size = 20,
vertex.label = V(graph)$degree,
vertex.label.color = "black",
vertex.label.font = 1,
vertex.label.family = "sans",
vertex.label.cex = 1,
vertex.color = "white")
plot(graph,
main="K Cores",
vertex.size = 20,
vertex.label = V(graph)$kCore,
vertex.label.color = "black",
vertex.label.font = 1,
vertex.label.family = "sans",
vertex.label.cex = 1,
vertex.color = "white")
...生成相同图形的图像(https://www.dropbox.com/s/unkkgodf8ppteyq/igraph.png?dl=0),左边显示度数,右边显示k-core。
基本上,左上角和右上角的节点应该同时具有3度和k核。剩下的应该是5,但是顶部中间的两个不是。
这是iGraph中的错误,还是我对k-core / graph.coreness
算法的理解错误?
答案 0 :(得分:3)
根据我对k核的理解,不应该连接8个节点,并且至少有5个节点都在k核中,值为5吗?然而,这8个中的两个被赋予k核值4和3。
没有。如果删除程度小于 k ,迭代的所有节点,k-core就是图形的一部分,这意味着如果某些节点的度数低于 k 由于删除了其他节点,您还必须删除这些节点。剩下的k-core是一个子图,其中所有节点的度数至少为 k 。在您的特定情况下,删除图中最左侧的节点并移除最顶层节点(在右上角)会降低5以下其他两个节点的度数 - 因此它们也将被删除。