
clear;clc
clear; clc;

cd /home/k1514724/subhadip/BBC/

files=dir('Netmat*.txt');

strngth(1:length(files),1)=zeros;
clustering_coefficient(1:length(files),1)=zeros;
characteristic_path_length(1:length(files),1)=zeros;
Eglob(1:length(files),1)=zeros;
% Eloc(1:length(files),1)=zeros;
BC(1:length(files),1)=zeros;
r(1:length(files),1)=zeros;

for l=1:length(files)
    
    connection_matrix(1:90,1:90)=zeros;
    files(l).name
    temp1=load(files(l).name);
    connection_matrix(1:90,1:90)=temp1;
    W_fix=weight_conversion(connection_matrix,'autofix');
%   connection_matrix=weight_conversion(W_fix, 'normalize');
    connection_matrix=W_fix;
    clear temp1; clear W_fix;
    
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %strength
    
     strngth(l,1) = mean(strengths_und(connection_matrix));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % clustering coefficient
   
   clustering_coefficient(l,1)=real(mean(clustering_coef_wu(connection_matrix)));
%  clustering_coefficient_nodal(chk,l)=clustering_coef_wu(thresholded_connection_matrix);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % characteristic path length 

   L=1./connection_matrix;
   L(L==Inf)=0;
   D=mean(distance_wei(L));
   characteristic_path_length(l,1)=charpath(D);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % global efficiency and local efficiency
   
   Eglob(l,1) = efficiency_wei(connection_matrix);
   % Eloc(l,1) = mean(efficiency_wei(connection_matrix,1));
%  Eloc_nodal(chk,l) = efficiency_wei(thresholded_connection_matrix,1);
   

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    % betweenness centrality
 BC(l,1)=mean(betweenness_wei(L));
% 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % Assortativity
 r(l,1)=assortativity_wei(connection_matrix,0);

end

save('/home/k1514724/subhadip/BBC/global/strength.txt','strngth','-ascii')
save('/home/k1514724/subhadip/BBC/global/ClusCoeff_network.txt','clustering_coefficient','-ascii')
save('/home/k1514724/subhadip/BBC/global/CharPathLength_network.txt','characteristic_path_length','-ascii')
save('/home/k1514724/subhadip/BBC/global/Eglob_network.txt','Eglob','-ascii')
save('/home/k1514724/subhadip/BBC/global/Betweenness_Centrality.txt','BC','-ascii')
save('/home/k1514724/subhadip/BBC/global/Assortativity.txt','r','-ascii')

