clc; clear all; close all; 
set(0,'DefaultAxesFontName', 'Times New Roman')
set(0,'DefaultAxesFontSize', 18)
% GSP box is needed to be installed to run this code (Also available in python) (https://epfl-lts2.github.io/gspbox-html/doc/base/)
% Add this into the MATLAB path 
gsp_start; 
G = gsp_minnesota(1);
L = double(full(G.L));
figure(1)
gsp_plot_graph(G)
figure(2)
stem(eig(L)); xlabel('Indices'); ylabel('Eigen values');

N = G.N;                     % number of nodes 
n = (1:N).'; 
f = exp(-(n./1050).^3);      % graph signal 

figure(1)
gsp_plot_graph(G)


G = gsp_compute_fourier_basis(G);
figure(2)
stem(n,G.e);xlabel('Node index');('Eigen values');

figure(3)
gsp_plot_signal(G,f);
f1 = f + 0.2*randn(N,1);     % graph signal + noise  

figure(4)
subplot(1,2,1)
gsp_plot_signal(G,f);
subplot(1,2,2)
gsp_plot_signal(G,f1);



l = 4;
h = @(x) 1./(1+l*x);
figure(5)
gsp_plot_filter(G,h);


f2 = gsp_filter(G,h,f1);   % Denoising 

figure(6)
subplot(1,2,1)
gsp_plot_signal(G,f);
subplot(1,2,2)
gsp_plot_signal(G,f2);