#This code operationalizes Everett's and Borgatti's (2005) equation 4.10 for two centralization. Code written by Jesse Sayles, 24 Feb 2015 #Citation: Everett M, Borgatti SP (2005) Extending centrality. Models and Methods in Social Network Analysis, eds Carrington P, Scott J, Wasserman S (Cambridge Univ Press, Cambridge, UK), pp 57-76. #The code takes a two mode network and calculates centralization. The code can handle isolates in the graph and will remove these before calculating centralization. So, centralization is calculated on a graph with no isolates. #create function for Everett and Borgatti (2005) equation 4.10 EverettBorgatti2modeCent<-function(twomode){ dcM1<-subset(rowSums(twomode),rowSums(twomode)>0) dcM2<-subset(colSums(twomode),colSums(twomode)>0) normM1<-dcM1/length(dcM2) normM2<-dcM2/length(dcM1) allNodesNorm<-c(normM1,normM2) if(max(dcM1)==max(max(dcM1),max(dcM2))){No<-length(dcM1);Ni<-length(dcM2)}else{No<-length(dcM2);Ni<-length(dcM1)} return ((sum(max(allNodesNorm)-allNodesNorm)) / (((((No*Ni)-Ni-No+1))*(Ni+No)) / (Ni*No))) } #this should come out to centralization = 1 test1<-matrix(c( 1,1,1,1,1, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0),nrow=5,ncol=5,byrow=T) EverettBorgatti2modeCent(test1) #this should also come out to centralization = 1 b/c we remove isos test2<-matrix(c( 1,1,0,1,1, 1,0,0,0,0, 0,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0),nrow=5,ncol=5,byrow=T) EverettBorgatti2modeCent(test2) #this should come out to centralization = 0 test3<-matrix(c( 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1),nrow=5,ncol=5,byrow=T) EverettBorgatti2modeCent(test3) #this should come out to centralization = NA b/c we divide by zero which we must interpret as centralization = 1 test4<-matrix(c( 1,1,1,1,1),nrow=1,ncol=5,byrow=T) EverettBorgatti2modeCent(test4)