//Complex Network Parameter caculation 
//Create by wubo
//06.7.25




//Calculate the degree distribution
function degree_result=degree_stat(g)
BA_degree=nodes_degrees(g);
SUM_degree=sum(BA_degree);
degree_result=zeros(1,max(BA_degree));
//disp(degree_result);

for i=1:g('node_number')
   temp=BA_degree(i);
   if(temp>0)
   degree_result(temp)=degree_result(temp)+1;
   end
end

for i=1:max(BA_degree);
degree_result(i)=degree_result(i)/g('node_number');
end

endfunction


//Calculate the <k>
function k1=kba_para(g)
k1=0;
g_fraction=degree_stat(g);
for i=1:max(nodes_degrees(g))
k1=k1+i*g_fraction(i);
end
endfunction


//Calculate the <k^2>
function k2=kfang_para(g)
k2=0;
g_fraction=degree_stat(g);
for i=1:max(nodes_degrees(g))
k2=k2+i^2*g_fraction(i);
end
endfunction

//Calculate the rich-club phenomenon
function node_k=nodek(g,k)
   
        m=1;
        mdegree=nodes_degrees(g); 
        if k>max(mdegree)
        error("k is larger than the maximum degree of the graph!! ");
        return -1;
        end
      for i=1:g.node_number
        if mdegree(i)>=k
           node_k(m)=i;
           m=m+1;
        end
       
      end
endfunction
          
function rc=rich_club(g,k)
endfunction






