14 lines
414 B
Mathematica
14 lines
414 B
Mathematica
|
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
|