简体   繁体   English

Igraph 的 R 度集中度 - 星形图未评估为 1

[英]Degree Centralization in Igraph for R - star graph not evaluated as 1

I'm working with a series of undirected small graphs using igraph in R. I'm interested in graph-level degree centralization, and am using the centr_degree function from igraph.我正在使用 R 中的 igraph 处理一系列无向小图。我对图级度集中化感兴趣,并且正在使用 igraph 中的 centr_degree 函数。

However, I noticed that even in cases of "star" graphs (one node connected to all other nodes, with no other connections), the code does not return a degree centralization of 1, though it seems from Freeman 1979 that they should.但是,我注意到即使在“星形”图(一个节点连接到所有其他节点,没有其他连接)的情况下,代码也不会返回 1 的度集中度,尽管从 Freeman 1979 看来它们应该如此。 Am I missing something in how this is supposed to be calculated?我是否遗漏了应该如何计算的内容?

Freeman 1979: http://leonidzhukov.net/hse/2014/socialnetworks/papers/freeman79-centrality.pdf弗里曼 1979: http : //leonidzhukov.net/hse/2014/socialnetworks/papers/freeman79-centrality.pdf

I've been dealing with the same issue.我一直在处理同样的问题。 I think something's wrong with the code to calculate the centralization, but I think it's written in C (R function uses ".Call") not in R so can't see it.我认为计算中心化的代码有问题,但我认为它是用 C 编写的(R 函数使用“.Call”)而不是 R,所以看不到它。 Below code produces a star graph and calculates igraph's centralization (which isn't 1).下面的代码生成一个星形图并计算 igraph 的中心化(不是 1)。

> adj = rbind(c(0,1,0,0,0),c(1,0,0,0,0),c(1,0,0,0,0),c(1,0,0,0,0),c(1,0,0,0,0))
> h = graph.adjacency(adj,mode="undirected")
> plot(h) # check star graph
> centralization.degree(h)
$res
[1] 4 1 1 1 1

$centralization
[1] 0.6

$theoretical_max
[1] 20

> centralize(degree(h),normalize=FALSE)
[1] 12

I think the actual problem may be an off-by-one error for the theoretical max.我认为实际问题可能是理论最大值的逐一错误。 Calculating it manually gives you 3 * 4 = 12, which agrees with use of centralize(normalize=FALSE), but the R output from centralization.degree seems to be 4 * 5 = 20. To solve your problem I'd suggest using the following code to normalize it yourself.手动计算它给你 3 * 4 = 12,这与使用 centralize(normalize=FALSE) 一致,但来自 centralization.degree 的 R 输出似乎是 4 * 5 = 20。为了解决你的问题,我建议使用下面的代码自己规范化。

> newCentralization = function(h) centralize(degree(h),normalize=FALSE)/((vcount(h)-1)*(vcount(h)-2))
> newCentralization(h)
[1] 1

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] igraph_1.0.1

loaded via a namespace (and not attached):
[1] magrittr_1.5

This is because the default option is loops=TRUE .这是因为默认选项是loops=TRUE The star graph achieves maximal centralization only if we don't consider loops.星形图只有在我们不考虑循环的情况下才能实现最大的中心化。 If we do consider them, the maximally centralized graph is like this:如果我们考虑它们,最大集中图是这样的:

在此处输入图片说明

In short, you might want centr_degree(g, loops=F) .简而言之,您可能需要centr_degree(g, loops=F)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM