-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_graph_signal.m
65 lines (55 loc) · 1.68 KB
/
create_graph_signal.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
function [x_bl,U,G,x_bl_noiseless] = create_graph_signal(graph_name, k, sigma_noise, N, notsupp_logi, params)
%
% function [x_bl,U,G,x_bl_noiseless] = create_graph_signal(graph_name, k, sigma_noise, N, notsupp_logi, params)
%
% graph_name = {'erdos', 'minnesota', 'ring', 'bunny', 'full', 'sensor','scale_free'}
% k : sparsity
% sigma_noise : noise standard deviation
% N (optional) : no. of vertices
% notsupp_logi (optional) : logical vector with entries not in the support
% params : extra parameters for specific graphs
%
% If support is not specified, the first k compoennets are used
%
if nargin < 3
error('Too few parameters');
end
if nargin == 3
N = 256;
end
%% Graph and GFT
switch(graph_name)
case 'erdos'
G = gsp_erdos_renyi(N,params);
case 'minnesota'
G = gsp_minnesota(); N = G.N;
case 'ring'
G = gsp_ring(N);
case 'bunny'
G = gsp_bunny(); N = G.N;
case 'full'
G = gsp_full_connected(N);
case 'sensor'
G = gsp_sensor(N);
case 'scale_free'
G = gsp_barabasi_albert(N);
case 'community'
G = gsp_community(N);
case '2dgrid'
G = gsp_2dgrid(sqrt(N),sqrt(N));
end
G.A = double(G.A);
G = gsp_create_laplacian(G,'normalized');
G = gsp_compute_fourier_basis(G);
U = G.U;
%% Signal on the graph
x = randn(N,1);
X = U'*x;
if nargin < 5
notsupp_logi = true(N,1);
notsupp_logi(1:k) = false;
end
X(notsupp_logi) = 0; % sparse
x_bl_noiseless = U*X;
x_bl = x_bl_noiseless + sigma_noise*randn(N,1);
end