14 lines
No EOL
414 B
Matlab
14 lines
No EOL
414 B
Matlab
function degcentrality(names, A)
|
|
counts = full(sum(A, 2));
|
|
ranks = sortrows([counts, (1:size(counts,1))'], 'descend');
|
|
|
|
for i = 1:size(ranks, 1)
|
|
fprintf("%14s %2d: ", names(ranks(i, 2)), ranks(i, 1)-1);
|
|
for j = 1:size(A, 2)
|
|
if ranks(i, 2) ~= j && A(ranks(i, 2), j) > 0
|
|
fprintf("%s, ", names(j));
|
|
end
|
|
end
|
|
fprintf("\n");
|
|
end
|
|
end |