-
Notifications
You must be signed in to change notification settings - Fork 0
/
RA.m
27 lines (24 loc) · 841 Bytes
/
RA.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [ simMatrix ] = RA( A )
% Compute the similarity matrix based on resource allocation (RA) index
% Reference:
% Zhou T, L¨¹ L, Zhang Y C. Predicting missing links via local information[J].
% The European Physical Journal B, 2009, 71(4): 623-630.
%
% INPUT:
% A: The adjacency matrix of a network
%
% OUTPUT:
% simMatrix: The result similarity matrix based on RA index
%
% Author: Peizhuo Wang ([email protected])
% Sep. 2016
AA = A ./ repmat(sum(A,2), [1,size(A, 1)]);
AA(isnan(AA)) = 0;
AA(isinf(AA)) = 0;
simMatrix = A * AA;
simMatrix = simMatrix .* A;% Only the original edge is considered
simMatrix_max = max(max(simMatrix));
simMatrix_min = min(min(simMatrix));
simMatrix = (simMatrix - ones(size(A, 1))*simMatrix_min) ./ (simMatrix_max-simMatrix_min);
simMatrix = simMatrix - diag(diag(simMatrix));
end