flow_coef_bd.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. function [fc,FC,total_flo] = flow_coef_bd(CIJ)
  2. %FLOW_COEF_BD Node-wise flow coefficients
  3. %
  4. % [hc,HC,total_flo] = flow_coef_bd(CIJ)
  5. %
  6. % Computes the flow coefficient for each node and averaged over the
  7. % network, as described in Honey et al. (2007) PNAS. The flow coefficient
  8. % is similar to betweenness centrality, but works on a local
  9. % neighborhood. It is mathematically related to the clustering
  10. % coefficient (cc) at each node as, fc+cc <= 1.
  11. %
  12. % input: CIJ, connection/adjacency matrix (binary, directed)
  13. % output: fc, flow coefficient for each node
  14. % FC, average flow coefficient over the network
  15. % total_flo, number of paths that "flow" across the central node
  16. %
  17. % Reference: Honey et al. (2007) Proc Natl Acad Sci U S A
  18. %
  19. % Olaf Sporns, Indiana University, 2007/2010/2012
  20. N = size(CIJ,1);
  21. % initialize ...
  22. fc = zeros(1,N);
  23. total_flo = fc;
  24. max_flo = fc;
  25. % loop over nodes
  26. for v=1:N
  27. % find neighbors - note: treats incoming and outgoing connections as equal
  28. [nb] = find(CIJ(v,:) + CIJ(:,v)');
  29. fc(v) = 0;
  30. if (~isempty(nb))
  31. CIJflo = -CIJ(nb,nb);
  32. for i=1:length(nb)
  33. for j=1:length(nb)
  34. if((CIJ(nb(i),v))==1)&&(CIJ(v,nb(j))==1)
  35. CIJflo(i,j) = CIJflo(i,j) + 1;
  36. end;
  37. end;
  38. end;
  39. total_flo(v) = sum(sum(double(CIJflo==1).*~eye(length(nb))));
  40. max_flo(v) = length(nb)^2-length(nb);
  41. fc(v) = total_flo(v)/max_flo(v);
  42. end;
  43. end;
  44. % handle nodes that are NaNs
  45. fc(isnan(fc)) = 0;
  46. FC = mean(fc);