-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrandspec.m
More file actions
77 lines (53 loc) · 1.08 KB
/
randspec.m
File metadata and controls
77 lines (53 loc) · 1.08 KB
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
%
% Draw the spectral transformation generated by a random sampling of a
% sparse graph.
%
% OUTPUT
% img-eps/randspec.eps
% img-eps/randspec.st.eps
%
path(path, '../webstore/analysis');
path(path, '../webstore/matlab');
font_size = 20;
n = 1000;
d = 3;
testsize = .24;
k = 100;
r = d * n;
a = sprand(n, n, r / (n*n));
[x y z] = find(a);
r = size(x,1);
p = randperm(r);
x = x(p);
y = y(p);
z = z(p);
r2 = round(r * testsize);
r1 = r - r2;
x1 = x(1:r1);
y1 = y(1:r1);
z1 = z(1:r1);
x2 = x(1+r1:end);
y2 = y(1+r1:end);
z2 = z(1+r1:end);
a1 = spconvert([x1 y1 z1]);
a2 = spconvert([x2 y2 z2]);
a1(n,n) = 0;
a2(n,n) = 0;
a1 = a1 + a1';
a2 = a2 + a2';
[u1, d1] = eigs(a1, k);
ubu = u1' * a2 * u1;
%
% UBU plot
%
imageubu(ubu);
print('-depsc', 'img-eps/randspec.eps'); close all;
%
% Spectral transformation plot
%
plot(diag(d1), diag(ubu), 'ok');
gridxy([0], [0], 'LineStyle', '--');
set(gca, 'FontSize', font_size);
xlabel('\lambda_k', 'FontSize', font_size);
ylabel('f(\lambda_k)', 'FontSize', font_size);
print('-depsc', 'img-eps/randspec.st.eps'); close all;