简体   繁体   中英

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.

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. Am I missing something in how this is supposed to be calculated?

Freeman 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. Below code produces a star graph and calculates igraph's centralization (which isn't 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.

> 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 . 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) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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