No BSD License
Highlights from
getOdC
from
getOdC
by Santiago Balestrini
Computes the Off-Diagonal Complexity as defined by J.C. Claussen.
|
| getOdC(g)
|
function [OdC] = getOdC(g)
% [OdC] = getOdC(g) where g is the adjacency matrix of a graph g
% Based on the algorithm by J.C. Claussen [Physica A 375 (2007) 365373]
g = g ~= 0; % Ensure that the adjacency matrix is binary
l = sum(g,1); % Degree Distribution
c = zeros(max(l)); % Preallocated for speed
a = zeros(size(g,1)); % Preallocated for speed
for m = 1:max(l)
for n = m:max(l)
i = find(l==m);
j = find(l==n);
if ~isempty(i) && ~isempty(j)
c(m,n) = sum(sum(g(i,j)));
end
end
end
for k = 1:length(l)
a(k) = sum(diag(c,k-1));
end
A = sum(a);
a = a/A;
h = a.*log(a);
h(isnan(h)) = 0; % 0*ln(0) is understood to be equal to 0 and not NaN
OdC = -sum(h);
|
|
Contact us at files@mathworks.com