-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrecoverMissing.m
30 lines (29 loc) · 1.08 KB
/
recoverMissing.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
28
29
30
function [ w ] = recoverMissing( r, lambda )
% Heuristic method for recovering a graph from an incomplete set of
% effective resistances. See Section 4.2 of "Learning Networks from Random
% Walk-Based Node Similarities".
%
% usage :
%
% input :
%
% * r: (n choose 2) length vector of pairwise effective resistances.
% r(i) = 0 if the i^th effective resistance is missing.
%
% Note that the ordering of the input vector matters. It should be
% consistent with the ordering used by pair2index.m and e.g. A2w.m
%
% * lambda: regularization parameter with which to run exact recover
% procedure. lambda >= 0.
%
% output :
%
% * w: (n choose 2) length vector of edge weights. Some may be
% negative. Consider cleaning up with utils/noisyRecoveryCleanup.m.
R = sparse(w2A(r));
% fill in in missing effective resistances with shortest path distances.
D = graphallshortestpaths(R);
R = R + (R == 0).*D;
% then just attempt exact recovery.
w = exactRecover(A2w(R),lambda);
end