Creating new measures in igraph

I want to create a function for the effective size of Burt. The formula is as follows:

Effective Size = n - 2t / n

  • where t is the number of connections (not counting connections with the ego)
  • n is the number of people on the network (not counting the ego).

I'm not sure where to start writing functions inside / for igraph.

Let me know if more details would be helpful ...

Thanks.

+4
source share
1 answer

First simulate a baseline:

require(igraph) alters = 50 ties = 10 set.seed(12345) edgelist = rbind(0, 1:alters) edgelist = cbind(edgelist, replicate(ties, sample(alters, 2))) g = graph(edgelist, directed=F) dev.new(width=5, height=5) plot(g, layout=layout.kamada.kawai) 

enter image description here

Then write a simple function to calculate the effective size. (Functions acting on g are well described in the igraph and in various examples over the network.)

 EffectiveSize <- function(g, ego=0) { n = neighbors(g, ego) t = length(E(g)[to(n) & !to(ego)]) n = length(n) n - 2 * t / n } 
 > EffectiveSize(g) [1] 49.6 
+7
source

Source: https://habr.com/ru/post/1379174/


All Articles