-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizationPageRankValues.m
98 lines (86 loc) · 1.99 KB
/
LocalizationPageRankValues.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%% LOCALIZATION OF THE PAGERANK MEASURE
% Examples for the stability and non locality section of the paper
%
% Code by:
% S. Cipolla - Università di Padova, Dipartimento di Matematica
% F. Durastante - Consiglio Nazionale delle Ricerche, Istituto per le
% Applicazioni del Calcolo "M. Picone"
% F. Tudisco - Gran Sasso Science Institute
clear; clc;
load('TestGraphs/adjnoun.mat');
A = Problem.A;
G = graph(A);
n = size(A,1);
e = ones(n,1);
figure(100);
h = plot(G,'Layout','subspace');
xy(:,1) = h.XData;
xy(:,2) = h.YData;
c = 0.90;
% Nonlocal pagerank for alpha = 0.01
alpha = 0.01;
W = G.distances();
W = 1./(W.^alpha);
W(W == inf) = 0;
D = (1./(W*e));
D(D == inf) = 0;
D = spdiags(D,0,n,n);
P = D*W;
x1 = powerpr(P,c);
% Nonlocal pagerank for alpha = 0.5
alpha = 0.5;
W = G.distances();
W = 1./(W.^alpha);
W(W == inf) = 0;
D = (1./(W*e));
D(D == inf) = 0;
D = spdiags(D,0,n,n);
P = D*W;
x2 = powerpr(P,c);
% Nonlocal pagerank for alpha = 3
alpha = 3;
W = G.distances();
W = 1./(W.^alpha);
W(W == inf) = 0;
D = (1./(W*e));
D(D == inf) = 0;
D = spdiags(D,0,n,n);
P = D*W;
x3 = powerpr(P,c);
% Standard pagerank
D = 1./(A*e);
D(D == inf) = 0;
D = spdiags(D,0,n,n);
P = D*A;
x4 = powerpr(P,c);
scalingnodesize = 15*1/max(max([x1,x2,x3,x4]));
figure(1);
subplot(2,2,1)
plot(G,'XData',xy(:,1),'YData',xy(:,2),'NodeCData',x1,'MarkerSize',scalingnodesize*x1,'NodeLabel',{})
axis tight
axis square
title('\alpha = 0.01');
xticks([]);
yticks([]);
subplot(2,2,2)
plot(G,'XData',xy(:,1),'YData',xy(:,2),'NodeCData',x2,'MarkerSize',scalingnodesize*x2,'NodeLabel',{})
axis tight
axis square
title('\alpha = 0.5');
xticks([]);
yticks([]);
subplot(2,2,3)
plot(G,'XData',xy(:,1),'YData',xy(:,2),'NodeCData',x3,'MarkerSize',scalingnodesize*x3,'NodeLabel',{})
axis tight
axis square
title('\alpha = 3');
xticks([]);
yticks([]);
subplot(2,2,4)
plot(G,'XData',xy(:,1),'YData',xy(:,2),'NodeCData',x4,'MarkerSize',scalingnodesize*x4,'NodeLabel',{})
axis tight
axis square
title('\alpha = \infty');
xticks([]);
yticks([]);
set(gcf,'color','white')