matching_ind_und.m 955 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. function M0 = matching_ind_und(CIJ)
  2. %MATCHING_IND_UND matching index
  3. %
  4. % M0 = MATCHING_IND_UND(CIJ) computes matching index for undirected
  5. % graph specified by adjacency matrix CIJ. Matching index is a measure of
  6. % similarity between two nodes' connectivity profiles (excluding their
  7. % mutual connection, should it exist).
  8. %
  9. % Inputs: CIJ, undirected adjacency matrix
  10. %
  11. % Outputs: M0, matching index matrix.
  12. %
  13. % Richard Betzel, Indiana University, 2013
  14. %
  15. CIJ0 = CIJ;
  16. K = sum(CIJ0);
  17. R = K ~= 0;
  18. N = sum(R);
  19. CIJ = CIJ0(R,R);
  20. I = ~eye(N);
  21. M = zeros(N,N);
  22. for i = 1:N
  23. c1 = CIJ(i,:);
  24. use = bsxfun(@or,c1,CIJ);
  25. use(:,i) = 0;
  26. use = use.*I;
  27. ncon1 = bsxfun(@times,use,c1);
  28. ncon2 = bsxfun(@times,use,CIJ);
  29. ncon = sum(ncon1 + ncon2,2);
  30. M(:,i) = 2*sum(ncon1 & ncon2,2)./ncon;
  31. end
  32. M = M.*I;
  33. M(isnan(M)) = 0;
  34. M0 = zeros(size(CIJ0));
  35. M0(R,R) = M;