Eco-network and structure hole

WEN, Tzai-Hung (NTU Geography)

0. Load packages for network analysis

library(sna)

1. Extract a graph

setwd("D:/R_Labs")
data<- "sample_adjmatrix.csv"
el<-read.table(data, header=T, row.names=1, sep=",")
m=as.matrix(el)
gplot(m, displaylabels=TRUE)

g.in <- ego.extract(m, neighborhood = "in")
(sub_m<-g.in$`23732`)
##       X23732 X23778 X23871 X58098
## 23732      0      1      1      1
## 23778      1      0      1      1
## 23871      1      1      0      1
## 58098      1      1      1      0
gplot(sub_m, displaylabels=TRUE)

g.out <- ego.extract(m, neighborhood = "out")
g.comb <- ego.extract(m, neighborhood = "combined")

2. Basic Measures of Ego-network

# no. of nodes in each ego-network
(size<-sapply(g.in, nrow))
## 23732 23778 23824 23871 58009 58098 58256 
##     4     5     2     5     3     6     2
(size<-size-1)
## 23732 23778 23824 23871 58009 58098 58256 
##     3     4     1     4     2     5     1
# graph density for each ego-network
(density<-gden(g.comb)) 
## 23732 23778 23824 23871 58009 58098 58256 
##   1.0   0.7   1.0   0.8   1.0   0.6   1.0

3. Measures of Structure Hole: effective size, efficiency, constraint, and hierarchy

library(egonet)
colnames(m) <- rownames(m) <- c("EGO", "1P", "2P","3P","4P","5P","6P")
gplot(m,displaylabels=TRUE)

index.egonet(m, ego.name="EGO")
##        effsize     constraint      outdegree       indegree     efficiency 
##      2.6666667      0.7511111      3.0000000      3.0000000      0.6111111 
##      hierarchy centralization           gden       ego.gden 
##      0.0000000      0.5000000      0.4761905      0.4666667
index.egonet(m, ego.name="6P")
##        effsize     constraint      outdegree       indegree     efficiency 
##      2.0000000      1.1600000      1.0000000      1.0000000      0.6111111 
##      hierarchy centralization           gden       ego.gden 
##      0.0000000      0.5000000      0.4761905      0.6000000