├── 3rdParty ├── anneal.patch ├── grasp_dependencies_list.m └── grasp_init_3rd_party.m ├── Duality ├── grasp_dual_graph.m ├── grasp_dual_time_series.m └── grasp_duality_bins_bounds.m ├── Graphs ├── Tools │ ├── grasp_adjacency_degreenorm.m │ ├── grasp_adjacency_gaussian.m │ ├── grasp_adjacency_knn.m │ ├── grasp_adjacency_matrix.m │ ├── grasp_adjacency_thresh.m │ ├── grasp_biggest_connected_component.m │ ├── grasp_degrees.m │ ├── grasp_distances_geo_layout.m │ ├── grasp_distances_layout.m │ ├── grasp_eigendecomposition.m │ ├── grasp_exportcsv.m │ ├── grasp_exportcsv_signal.m │ ├── grasp_farthest.m │ ├── grasp_frequencies.m │ ├── grasp_importcsv.m │ ├── grasp_incidence_matrix.m │ ├── grasp_is_directed.m │ ├── grasp_lapl_eigval_upper_bound.m │ ├── grasp_laplacian_normalized.m │ ├── grasp_laplacian_standard.m │ ├── grasp_largest_connected_component.m │ ├── grasp_layout.m │ ├── grasp_layout_spectral.m │ ├── grasp_maximally_connected_subgraphs.m │ ├── grasp_nb_nodes.m │ ├── grasp_struct.m │ ├── grasp_subgraph.m │ ├── grasp_symetrise_unweighted.m │ └── grasp_voronoi_areas.m ├── grasp_barabasi_albert.m ├── grasp_clique.m ├── grasp_comete.m ├── grasp_complete.m ├── grasp_directed_cycle.m ├── grasp_directed_grid.m ├── grasp_directed_path.m ├── grasp_directed_torus.m ├── grasp_erdos_renyi.m ├── grasp_minnesota.m ├── grasp_non_directed_cycle.m ├── grasp_non_directed_grid.m ├── grasp_non_directed_path.m ├── grasp_non_directed_torus.m ├── grasp_plane_knn.m ├── grasp_plane_rnd.m ├── grasp_plane_rnd_grad_samp.m ├── grasp_plane_rnd_pseudo_regular.m ├── grasp_random_bipartite.m ├── grasp_random_regular.m ├── grasp_torus_knn.m ├── grasp_two_moons_knn.m ├── grasp_watts_strogatz.m ├── minnesota_coarse.png └── minnesota_fine.png ├── LICENCE.txt ├── LICENSE.txt ├── LaTeX ├── README ├── tikzbabel.sty ├── tikzcolorscale.sty ├── tikzgraph.sty └── tikzmatrix.sty ├── Operators ├── grasp_apply_filter.m ├── grasp_build_translations_epfl.m ├── grasp_coherence.m ├── grasp_convolution.m ├── grasp_dft_matrix.m ├── grasp_filter_cheb.m ├── grasp_filter_kernel_to_poly.m ├── grasp_filter_struct.m ├── grasp_fourier.m ├── grasp_fourier_inverse.m ├── grasp_generalized_modulation.m ├── grasp_generalized_translation.m ├── grasp_isometrize_operator.m ├── grasp_semi_supervised.m ├── grasp_translation.m └── grasp_wft.m ├── Plotting ├── grasp_animate_iterated_operator_gui.fig ├── grasp_animate_iterated_operator_gui.m ├── grasp_generate_gif.m ├── grasp_gft_gui.fig ├── grasp_gft_gui.m ├── grasp_open_figure_name.m ├── grasp_scatter_update.m ├── grasp_show_fouriermodes.m ├── grasp_show_graph.m ├── grasp_show_matrix.m ├── grasp_show_spectral_response.m ├── grasp_show_transform.m └── grasp_subaxis.m ├── README.md ├── RELEASENOTES.md ├── Signals ├── grasp_delta.m ├── grasp_gaussian_signal_realization.m ├── grasp_gfm_l1.m ├── grasp_heat_kernel.m ├── grasp_intrinsic_stationary_realization.m ├── grasp_signal_spread.m └── grasp_signal_spread_weighted.m ├── Stats ├── grasp_empirical_correlation.m └── grasp_empirical_pearson_correlation.m ├── ThirdPartyToolboxes.md ├── Util ├── grasp_blueredcolormap.mat ├── grasp_clean_pdf_export.m ├── grasp_from_gspbox.m ├── grasp_is_octave.m ├── grasp_merge_structs.m ├── grasp_parse_varargin.m ├── grasp_set_blue_red_colormap.m ├── grasp_set_figure_size.m ├── grasp_subaxis_matrix_dimensions.m ├── grasp_ternary_op.m └── grasp_to_gspbox.m ├── doc ├── generate_doc.sh ├── matlabhelp2mediawiki.awk └── tuto.mwk ├── grasp_add_dependency.m ├── grasp_bibliography.m ├── grasp_install.m ├── grasp_remove_dependency.m ├── grasp_start.m ├── grasp_start_opt_3rd_party.m ├── grasp_stop.m └── grasp_translation_page.m /3rdParty/anneal.patch: -------------------------------------------------------------------------------- 1 | --- a/grasp/3rdParty/anneal/anneal.m 2014-02-12 12:20:42.000000000 +0100 2 | +++ b/grasp/3rdParty/anneal/anneal.m 2015-11-13 14:53:50.946056840 +0100 3 | @@ -99,7 +99,7 @@ 4 | 5 | def = struct(... 6 | 'CoolSched',@(T) (.8*T),... 7 | - 'Generator',@(x) (x+(randperm(length(x))==length(x))*randn/100),... 8 | + 'Generator',@(x, T) (x+(randperm(length(x))==length(x))*randn/100),... 9 | 'InitTemp',1,... 10 | 'MaxConsRej',1000,... 11 | 'MaxSuccess',20,... 12 | @@ -172,7 +172,7 @@ 13 | end 14 | end 15 | 16 | - newparam = newsol(current); 17 | + newparam = newsol(current, T); 18 | newenergy = loss(newparam); 19 | 20 | if (newenergy < minF), 21 | -------------------------------------------------------------------------------- /Duality/grasp_dual_graph.m: -------------------------------------------------------------------------------- 1 | %Maps a graph to a time series using various approaches. 2 | % 3 | % graph = GRASP_DUAL_GRAPH(ts) creates a graph from a time_series using 4 | % [Campanharo et al. 2011, PLOS] 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_dual_graph(ts) 44 | error('Not yet implemented!'); 45 | end -------------------------------------------------------------------------------- /Duality/grasp_duality_bins_bounds.m: -------------------------------------------------------------------------------- 1 | %Helper function to compute bin boundaries from their centers. 2 | % 3 | % bounds = GRASP_DUALITY_BINS_BOUNDS(centers, min_value, max_value) 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | 8 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 9 | % Inria, FRANCE (2015-11-01) 10 | % 11 | % benjamin.girault@ens-lyon.fr 12 | % 13 | % This software is a computer program whose purpose is to provide a Matlab 14 | % / Octave toolbox for handling and displaying graph signals. 15 | % 16 | % This software is governed by the CeCILL license under French law and 17 | % abiding by the rules of distribution of free software. You can use, 18 | % modify and/ or redistribute the software under the terms of the CeCILL 19 | % license as circulated by CEA, CNRS and INRIA at the following URL 20 | % "http://www.cecill.info". 21 | % 22 | % As a counterpart to the access to the source code and rights to copy, 23 | % modify and redistribute granted by the license, users are provided only 24 | % with a limited warranty and the software's author, the holder of the 25 | % economic rights, and the successive licensors have only limited 26 | % liability. 27 | % 28 | % In this respect, the user's attention is drawn to the risks associated 29 | % with loading, using, modifying and/or developing or reproducing the 30 | % software by the user in light of its specific status of free software, 31 | % that may mean that it is complicated to manipulate, and that also 32 | % therefore means that it is reserved for developers and experienced 33 | % professionals having in-depth computer knowledge. Users are therefore 34 | % encouraged to load and test the software's suitability as regards their 35 | % requirements in conditions enabling the security of their systems and/or 36 | % data to be ensured and, more generally, to use and operate it in the 37 | % same conditions as regards security. 38 | % 39 | % The fact that you are presently reading this means that you have had 40 | % knowledge of the CeCILL license and that you accept its terms. 41 | 42 | function bounds = grasp_duality_bins_bounds(centers, min_value, max_value) 43 | N = numel(centers); 44 | [centers_sorted, IX] = sort(centers); 45 | tmp = [min_value ; centers_sorted(1:(N-1)) + (centers_sorted(2:N) - centers_sorted(1:(N-1))) / 2 ; max_value]; 46 | tmp1 = tmp(1:(end - 1)); 47 | tmp2 = tmp(2:end); 48 | bounds(IX, [1 2]) = [tmp1 tmp2]; 49 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_adjacency_degreenorm.m: -------------------------------------------------------------------------------- 1 | %Normalize the adjacency matrix using a power a of degree matrix. 2 | % 3 | % graph = GRASP_ADJACENCY_DEGREENORM(graph, lambda) normalize the 4 | % adjacency matrix by A_norm = D^-lambda * A * D^-lambda. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, University of Southern California, USA 10 | % (2017-2018). 11 | % 12 | % benjamin.girault@usc.edu 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_adjacency_degreenorm(graph, lambda) 44 | d = diag(grasp_degrees(graph)); 45 | Dl = diag(d .^ (-lambda)); 46 | A = Dl * graph.A * Dl; 47 | if grasp_is_directed(graph) 48 | graph.A = A; 49 | else 50 | % Ensures that the graph stays undirected after normalization. 51 | graph.A = (A + A') / 2; 52 | end 53 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_adjacency_knn.m: -------------------------------------------------------------------------------- 1 | %Constructs an adjacency matrix using the k nearest neighbors, assuming 2 | %that the adjacency matrix is a similarity matrix (bigger weights for closer 3 | %nodes). 4 | % 5 | % A = GRASP_ADJACENCY_KNN(graph, k) returns an adjacency matrix A 6 | % constructed from the adjacency matrix using KNN. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-11-01) 14 | % Copyright Benjamin Girault, University of Southern California, USA 15 | % (2017). 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % benjamin.girault@usc.edu 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function A = grasp_adjacency_knn(graph, k) 50 | %% Intializations 51 | N = grasp_nb_nodes(graph); 52 | directed = grasp_is_directed(graph); 53 | 54 | %% Compute the k nearest neighbors 55 | I(2 * k * N) = 0; 56 | J(2 * k * N) = 0; 57 | W(2 * k * N) = 0; 58 | nb_entries = 0; 59 | vertex_marking = zeros(N); 60 | for i = 1:N 61 | mask = [1:(i-1) (i+1):N]; 62 | [~, IX] = sort(graph.A(i, mask), 'descend'); 63 | IX = mask(IX); 64 | for j = IX(1:k) 65 | if vertex_marking(i, j) == 0 66 | I(nb_entries + 1) = i; 67 | J(nb_entries + 1) = j; 68 | W(nb_entries + 1) = graph.A(i, j); 69 | vertex_marking(i, j) = 1; 70 | nb_entries = nb_entries + 1; 71 | end 72 | if ~directed && vertex_marking(j, i) == 0 73 | I(nb_entries + 1) = j; 74 | J(nb_entries + 1) = i; 75 | W(nb_entries + 1) = graph.A(j, i); 76 | vertex_marking(j, i) = 1; 77 | nb_entries = nb_entries + 1; 78 | end 79 | end 80 | end 81 | A = sparse(I(1:nb_entries), J(1:nb_entries), W(1:nb_entries), N, N); 82 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_adjacency_matrix.m: -------------------------------------------------------------------------------- 1 | %Returns the adjacency matrix of a graph 2 | % 3 | % A = GRASP_ADJACENCY_MATRIX(graph) 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | 8 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 9 | % Inria, FRANCE (2015-11-01) 10 | % 11 | % benjamin.girault@ens-lyon.fr 12 | % 13 | % This software is a computer program whose purpose is to provide a Matlab 14 | % / Octave toolbox for handling and displaying graph signals. 15 | % 16 | % This software is governed by the CeCILL license under French law and 17 | % abiding by the rules of distribution of free software. You can use, 18 | % modify and/ or redistribute the software under the terms of the CeCILL 19 | % license as circulated by CEA, CNRS and INRIA at the following URL 20 | % "http://www.cecill.info". 21 | % 22 | % As a counterpart to the access to the source code and rights to copy, 23 | % modify and redistribute granted by the license, users are provided only 24 | % with a limited warranty and the software's author, the holder of the 25 | % economic rights, and the successive licensors have only limited 26 | % liability. 27 | % 28 | % In this respect, the user's attention is drawn to the risks associated 29 | % with loading, using, modifying and/or developing or reproducing the 30 | % software by the user in light of its specific status of free software, 31 | % that may mean that it is complicated to manipulate, and that also 32 | % therefore means that it is reserved for developers and experienced 33 | % professionals having in-depth computer knowledge. Users are therefore 34 | % encouraged to load and test the software's suitability as regards their 35 | % requirements in conditions enabling the security of their systems and/or 36 | % data to be ensured and, more generally, to use and operate it in the 37 | % same conditions as regards security. 38 | % 39 | % The fact that you are presently reading this means that you have had 40 | % knowledge of the CeCILL license and that you accept its terms. 41 | 42 | function A = grasp_adjacency_matrix(graph) 43 | A = graph.A; 44 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_adjacency_thresh.m: -------------------------------------------------------------------------------- 1 | %Constructs a thresholded adjacency matrix, assuming that the adjacency 2 | %matrix is a similarity matrix (bigger weights for closer nodes). 3 | % 4 | % A = GRASP_ADJACENCY_THRESH(graph, thresh) returns an adjacency matrix A 5 | % thresholded using the minimum weight thresh. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % Copyright Benjamin Girault, University of Sourthern California, Los 14 | % Angeles, California, USA (2017-2018) 15 | % 16 | % benjamin.girault@ens-lyon.fr 17 | % benjamin.girault@usc.edu 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function A = grasp_adjacency_thresh(graph, thresh) 49 | A = sparse(graph.A .* (graph.A >= thresh)); 50 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_biggest_connected_component.m: -------------------------------------------------------------------------------- 1 | %Calls directly GRASP_LARGEST_CONNECTED_COMPONENT. DEPRECATED. 2 | % 3 | % Authors: 4 | % - Benjamin Girault 5 | 6 | % Copyright Benjamin Girault, University of Sourthern California, Los 7 | % Angeles, California, USA (2019) 8 | % 9 | % benjamin.girault@ens-lyon.fr 10 | % benjamin.girault@usc.edu 11 | % 12 | % This software is a computer program whose purpose is to provide a Matlab 13 | % / Octave toolbox for handling and displaying graph signals. 14 | % 15 | % This software is governed by the CeCILL license under French law and 16 | % abiding by the rules of distribution of free software. You can use, 17 | % modify and/ or redistribute the software under the terms of the CeCILL 18 | % license as circulated by CEA, CNRS and INRIA at the following URL 19 | % "http://www.cecill.info". 20 | % 21 | % As a counterpart to the access to the source code and rights to copy, 22 | % modify and redistribute granted by the license, users are provided only 23 | % with a limited warranty and the software's author, the holder of the 24 | % economic rights, and the successive licensors have only limited 25 | % liability. 26 | % 27 | % In this respect, the user's attention is drawn to the risks associated 28 | % with loading, using, modifying and/or developing or reproducing the 29 | % software by the user in light of its specific status of free software, 30 | % that may mean that it is complicated to manipulate, and that also 31 | % therefore means that it is reserved for developers and experienced 32 | % professionals having in-depth computer knowledge. Users are therefore 33 | % encouraged to load and test the software's suitability as regards their 34 | % requirements in conditions enabling the security of their systems and/or 35 | % data to be ensured and, more generally, to use and operate it in the 36 | % same conditions as regards security. 37 | % 38 | % The fact that you are presently reading this means that you have had 39 | % knowledge of the CeCILL license and that you accept its terms. 40 | 41 | function [graph, nodes] = grasp_biggest_connected_component(graph) 42 | warning('DEPRECATED! ''Use grasp_largest_connected_component''.'); 43 | if nargout == 1 44 | graph = grasp_largest_connected_component(graph); 45 | else 46 | [graph, nodes] = grasp_largest_connected_component(graph); 47 | end 48 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_degrees.m: -------------------------------------------------------------------------------- 1 | %Computes the degrees of a graph. 2 | % 3 | % D = GRASP_DEGREES(graph) computes degree matrix D of graph. If graph is 4 | % directed, then D is the out-degree matrix. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function D = grasp_degrees(graph) 44 | D = diag(sum(graph.A, 2)); 45 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_distances_geo_layout.m: -------------------------------------------------------------------------------- 1 | %Construct an approximate distance matrix from geographic coordinates. Uses 2 | %the Haversine formula, in combination with an approximate latitude 3 | %dependent earth radius. 4 | % 5 | % graph = GRASP_DISTANCES_GEO_LAYOUT(graph) computes the approximate 6 | % distance matrix in kilometers. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, University of Sourthern California, Los 12 | % Angeles, California, USA (2019) 13 | % 14 | % benjamin.girault@usc.edu 15 | % 16 | % This software is a computer program whose purpose is to provide a Matlab 17 | % / Octave toolbox for handling and displaying graph signals. 18 | % 19 | % This software is governed by the CeCILL license under French law and 20 | % abiding by the rules of distribution of free software. You can use, 21 | % modify and/ or redistribute the software under the terms of the CeCILL 22 | % license as circulated by CEA, CNRS and INRIA at the following URL 23 | % "http://www.cecill.info". 24 | % 25 | % As a counterpart to the access to the source code and rights to copy, 26 | % modify and redistribute granted by the license, users are provided only 27 | % with a limited warranty and the software's author, the holder of the 28 | % economic rights, and the successive licensors have only limited 29 | % liability. 30 | % 31 | % In this respect, the user's attention is drawn to the risks associated 32 | % with loading, using, modifying and/or developing or reproducing the 33 | % software by the user in light of its specific status of free software, 34 | % that may mean that it is complicated to manipulate, and that also 35 | % therefore means that it is reserved for developers and experienced 36 | % professionals having in-depth computer knowledge. Users are therefore 37 | % encouraged to load and test the software's suitability as regards their 38 | % requirements in conditions enabling the security of their systems and/or 39 | % data to be ensured and, more generally, to use and operate it in the 40 | % same conditions as regards security. 41 | % 42 | % The fact that you are presently reading this means that you have had 43 | % knowledge of the CeCILL license and that you accept its terms. 44 | 45 | function distances = grasp_distances_geo_layout(graph) 46 | R = approximate_radius(graph.layout(:, 2)); 47 | N = grasp_nb_nodes(graph); 48 | tmp_1 = repmat(1:N, N, 1); 49 | tmp_2 = tmp_1'; 50 | distances = haversine_approx(graph.layout(tmp_1(:), 2), graph.layout(tmp_1(:), 1), graph.layout(tmp_2(:), 2), graph.layout(tmp_2(:), 1), R); 51 | distances = reshape(distances, N, N); 52 | end 53 | 54 | function [dist_haversine,dist_angular,dist_lat,dist_lon] = haversine_approx(latitude_1, longitude_1, latitude_2, longitude_2, radius) 55 | dist_lat = deg2rad(latitude_2 - latitude_1); 56 | dist_lon = deg2rad(longitude_2 - longitude_1); 57 | latitude_1 = deg2rad(latitude_1); 58 | latitude_2 = deg2rad(latitude_2); 59 | dist_angular = sqrt((sin(dist_lat ./ 2)) .^ 2 + cos(latitude_1) .* cos(latitude_2) .* (sin(dist_lon ./ 2)) .^ 2); 60 | dist_haversine = 2 * radius .* asin(dist_angular); 61 | end 62 | 63 | function R = approximate_radius(latitudes) 64 | R_equator = 6378; 65 | R_pole = 6357; 66 | phi = (max(latitudes) + min(latitudes)) / 2; 67 | s = sin(deg2rad(phi)); 68 | c = cos(deg2rad(phi)); 69 | R = sqrt(((R_equator ^ 2 * c) ^ 2 + (R_pole ^ 2 * s) ^ 2) / ((R_equator * c) ^ 2 + (R_pole * s) ^ 2)); 70 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_distances_layout.m: -------------------------------------------------------------------------------- 1 | %Creates a distances matrix from a graph layout. 2 | % 3 | % distances = GRASP_DISTANCES_LAYOUT(graph) Returns the distances matrix 4 | % computed using Euclidean distances in the plane of the layout. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % Copyright Benjamin Girault, École Nationale de la Statistique et de 13 | % l'Analyse de l'Information, Bruz, FRANCE (2020-2021) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % benjamin.girault@ensai.fr 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function distances = grasp_distances_layout(graph) 48 | N = size(graph.distances, 1); 49 | squared_norms = sum(graph.layout .^ 2, 2); 50 | distances = sqrt(abs(squared_norms + squared_norms' - 2 * (graph.layout * graph.layout'))); 51 | end 52 | -------------------------------------------------------------------------------- /Graphs/Tools/grasp_exportcsv.m: -------------------------------------------------------------------------------- 1 | %Export a graph structure in CSV files for LaTeX. 2 | % 3 | % GRASP_EXPORTCSV(graph, nodes_file, edges_file) creates the two files 4 | % nodes_file and edges_file that can be used by LaTeX package stemgraph. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function grasp_exportcsv(graph, nodes_file, edges_file) 44 | N = grasp_nb_nodes(graph); 45 | fileID = fopen(nodes_file,'w'); 46 | fprintf(fileID,'X,Y,Name\n'); 47 | for i = 1:N 48 | fprintf(fileID, '%d,%d,%d\n', graph.layout(i, 1) / 10, graph.layout(i, 2) / 10, i); 49 | end 50 | fclose(fileID); 51 | 52 | fileID = fopen(edges_file, 'w'); 53 | fprintf(fileID,'n1,n2,w12,oriented\n'); 54 | for i = 1:N 55 | for j = 1:N 56 | directed = full(graph.A(i,j) ~= graph.A(j,i)); 57 | if ~directed && i > j 58 | continue; 59 | end 60 | if (abs(graph.A(i, j)) > 0) 61 | fprintf(fileID, '%d,%d,%e,%d\n', i, j, full(graph.A(i, j)), directed); 62 | end 63 | end 64 | end 65 | fclose(fileID); 66 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_exportcsv_signal.m: -------------------------------------------------------------------------------- 1 | %Export a graph signal in a CSV file. 2 | % 3 | % GRASP_EXPORTCSV_SIGNAL(graph, signal, signal_file) creates the CSV file 4 | % signal_file with the first column as the vertex ID, and the subsequent 5 | % columns as signal(i, :) for vertex i. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % Copyright Benjamin Girault, University of Sourthern California, Los 14 | % Angeles, California, USA (2017-2018) 15 | % 16 | % benjamin.girault@ens-lyon.fr 17 | % benjamin.girault@usc.edu 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function grasp_exportcsv_signal(graph, signal, signal_file) 49 | N = grasp_nb_nodes(graph); 50 | 51 | fileID = fopen(signal_file,'w'); 52 | fprintf(fileID, 'n'); 53 | for i = 1:size(signal, 2) 54 | fprintf(fileID, ',value%d', i); 55 | end 56 | fprintf(fileID, '\n'); 57 | for i = 1:N 58 | fprintf(fileID, '%d', i); 59 | for j = 1:size(signal, 2) 60 | fprintf(fileID, ',%f', full(signal(i, j))); 61 | end 62 | fprintf(fileID, '\n'); 63 | end 64 | fclose(fileID); 65 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_frequencies.m: -------------------------------------------------------------------------------- 1 | %Computes the reduced frequencies associated to each Fourier mode of a 2 | %graph. See [Girault et al. 2015, IEEE SPL]. 3 | % 4 | % freqs = GRASP_FREQUENCIES(graph) returns the graph frequencies. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % Copyright Benjamin Girault, University of Sourthern California, Los 13 | % Angeles, California, USA (2018-2019) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % benjamin.girault@usc.edu 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function freqs = grasp_frequencies(graph) 48 | if ~isfield(graph, 'fourier_version') || strcmp(graph.fourier_version, 'n.a.') 49 | error('Fourier transform not performed!'); 50 | end 51 | 52 | if strcmp(graph.fourier_version, 'standard laplacian') || strcmp(graph.fourier_version, 'irregularity-aware') 53 | freqs = 0.5 * abs(sqrt(graph.eigvals / grasp_lapl_eigval_upper_bound(graph))); 54 | elseif strcmp(graph.fourier_version, 'normalized laplacian') 55 | freqs = 0.5 * abs(sqrt(graph.eigvals / 2)); 56 | % elseif 57 | % freqs = 0.5 * abs(sqrt(graph.eigvals / max(graph.eigvals))); 58 | elseif strcmp(graph.fourier_version, 'graph shift') || strcmp(graph.fourier_version, 'diagonalization') 59 | freqs = 0.25 * (1 - graph.eigvals / max(abs(graph.eigvals))); 60 | else 61 | error('Unknown Fourier transform!'); 62 | end 63 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_importcsv.m: -------------------------------------------------------------------------------- 1 | %Import a graph structure from CSVs. 2 | % 3 | % graph = GRASP_IMPORTCSV(nodes_file, edges_file) reads the two files 4 | % nodes_file and edges_file and outputs the graph. This function is the 5 | % inverse of GRASP_EXPORTCSV. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function graph = grasp_importcsv(nodes_file, edges_file) 45 | graph = grasp_struct; 46 | 47 | %% Nodes 48 | nodes = csvread(nodes_file, 1); 49 | graph.layout = 10 * nodes(nodes(:, 3), 1:2); 50 | N = size(graph.layout, 1); 51 | graph.A = zeros(N); 52 | 53 | %% Edges 54 | edges = csvread(edges_file, 1); 55 | for i = 1:size(edges, 1) 56 | graph.A(edges(i, 1), edges(i, 2)) = edges(i, 3); 57 | if ~edges(i, 4) 58 | graph.A(edges(i, 2), edges(i, 1)) = edges(i, 3); 59 | end 60 | end 61 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_incidence_matrix.m: -------------------------------------------------------------------------------- 1 | %Builds the incidence matrix of a graph 2 | % 3 | % E = GRASP_INCIDENCE_MATRIX(graph) builds the m-by-3 incidence matrix E 4 | % from graph. E(1,:) and E(2,:) are the nodes and E(3,:) the weight. If 5 | % graph is non directed, edges appear only once in E. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function E = grasp_incidence_matrix(graph) 45 | [I, J, W] = find(graph.A); 46 | E = [I J W]; 47 | if ~grasp_is_directed(graph); 48 | E = E(E(:, 1) < E(:, 2), :); 49 | end 50 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_is_directed.m: -------------------------------------------------------------------------------- 1 | %Check if a graph has directed edges. 2 | % 3 | % isdir = GRASP_IS_DIRECTED(graph) returns true if graph has directed 4 | % edges, false otherwise. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function isdir = grasp_is_directed(graph) 44 | isdir = sum(sum(graph.A - graph.A' ~= 0)) > 0; 45 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_lapl_eigval_upper_bound.m: -------------------------------------------------------------------------------- 1 | %Laplacian eigenvalue upper bound. Uses Corollary 3.3 of [K. CH. Das '07]. 2 | % 3 | % T = GRASP_LAPL_EIGVAL_UPPER_BOUND(graph) returns an upper bound of the 4 | % eigenvalues of the standard Laplacian. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function rho = grasp_lapl_eigval_upper_bound(graph) 44 | d = diag(grasp_degrees(graph)); 45 | d_bar = (graph.A * d) ./ d; 46 | rho = max(sqrt(2 * d .* (d + d_bar))); 47 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_laplacian_standard.m: -------------------------------------------------------------------------------- 1 | %Constructs the standard Laplacian of a non directed graph. If the graph is 2 | %directed, with non-negative weights, use Fan Chung combinatorial Laplacian 3 | %[Laplacians and the Cheeger Inequality for Directed Graphs]. 4 | % 5 | % L = GRASP_LAPLACIAN_STANDARD(graph) returns the Laplacian of the 6 | % graph provided using its adjacency matrix. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-11-01) 14 | % Copyright Benjamin Girault, University of Sourthern California, Los 15 | % Angeles, California, USA (2018-2019) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % benjamin.girault@usc.edu 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function L = grasp_laplacian_standard(graph) 50 | %% Check for self-loops 51 | if sum(abs(diag(graph.A))) > 0 52 | error('GraSP:LaplacianStandard:UnsupportedSelfLoops', 'Error: unsupported graph with self-loops!'); 53 | end 54 | 55 | %% Compute L 56 | if grasp_is_directed(graph) 57 | %% Check that we can convert the adjacency matrix into a random walk matrix P 58 | if sum(graph.A(:) < 0) > 0 59 | error('GraSP:LaplacianStandard:UnsupportedNegativeWeights', 'Error: directed graph with negative weights!'); 60 | end 61 | 62 | %% Directed graph Laplacian deriving from F. Chung definition 63 | Dout = grasp_degrees(graph); 64 | P = Dout ^ -1 * graph.A; 65 | [pi, ~] = eigs(P', 1, 1); % Closest left eigenvector of P to eigenvalue 1 (stationary distribution of the RW) 66 | Pi = diag(pi); 67 | L = Pi - (Pi * P + P' * Pi) / 2; 68 | else 69 | %% Classic Combinatorial Laplacian for undirected graph 70 | L = grasp_degrees(graph) - grasp_adjacency_matrix(graph); 71 | end 72 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_largest_connected_component.m: -------------------------------------------------------------------------------- 1 | %Selects the subgraph associated to the largest connected component of a 2 | %graph. 3 | % 4 | % graph = GRASP_LARGEST_CONNECTED_COMPONENT(graph) find the largest 5 | % connected component and returns it. 6 | % 7 | % [..., nodes] = GRASP_LARGEST_CONNECTED_COMPONENT(...) also returns 8 | % the set of selected nodes. 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015) 16 | % Copyright Benjamin Girault, University of Sourthern California, Los 17 | % Angeles, California, USA (2017-2019) 18 | % 19 | % benjamin.girault@ens-lyon.fr 20 | % benjamin.girault@usc.edu 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function [graph, nodes] = grasp_largest_connected_component(graph) 52 | % Load the matlab-bgl toolbox for 'components' 53 | grasp_start_opt_3rd_party('MatlabBGL'); 54 | 55 | % Find the largest connected component 56 | [conn_comps, sizes] = components(sparse(graph.A)); 57 | [~, largest_cc] = max(sizes); 58 | nodes = find(conn_comps == largest_cc); 59 | 60 | % Select only the nodes of that component 61 | graph = grasp_subgraph(graph, nodes); 62 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_layout_spectral.m: -------------------------------------------------------------------------------- 1 | %Computes a layout of a graph using its spectral properties. 2 | %Uses the random walk Laplacian eigenvectors to build the embedding. 3 | % 4 | % layout = GRASP_LAYOUT_SPECTRAL(graph) given a graph, computes a layout 5 | % (i.e. a n-by-2 matrix) of the nodes. 6 | % 7 | % GRASP_LAYOUT_SPECTRAL(..., options) optional parameters: 8 | % 9 | % options.normalize_coordinates: whether or not the coordinates returned 10 | % need to be normalized to the square [0,10] (default: true). 11 | % 12 | % options.dimension: dimension of the layout (default: 2 for 2D). 13 | % 14 | % Authors: 15 | % - Benjamin Girault 16 | 17 | % Copyright Benjamin Girault, University of Sourthern California, Los 18 | % Angeles, California, USA (2017-2019) 19 | % 20 | % benjamin.girault@usc.edu 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function layout = grasp_layout_spectral(graph, varargin) 52 | %% Parameters 53 | default_param = struct(... 54 | 'normalize_coordinates', true,... 55 | 'dimension', 2); 56 | if nargin == 1 57 | options = struct; 58 | elseif nargin > 2 59 | options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 60 | else 61 | options = varargin{1}; 62 | end 63 | options = grasp_merge_structs(default_param, options); 64 | 65 | %% Main code 66 | N = grasp_nb_nodes(graph); 67 | [layout, ~] = eigs(graph.A, grasp_degrees(graph), options.dimension + 1); 68 | layout = layout(:, 2:(options.dimension + 1)); 69 | if nargin == 1 || options.normalize_coordinates 70 | layout = 10 * (layout - ones(N, 1) * min(layout)) ./ (ones(N, 1) * (max(layout) - min(layout))); 71 | end 72 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_maximally_connected_subgraphs.m: -------------------------------------------------------------------------------- 1 | %Returns a cell array of subgraphs that are maximally connected. 2 | % 3 | % graphs = GRASP_MAXIMALLY_CONNECTED_SUBGRAPHS(graph) compute the 4 | % maximally connected subgraphs of graph and return them in the 5 | % struct array graphs. 6 | % 7 | % [..., nodes] = GRASP_MAXIMALLY_CONNECTED_SUBGRAPHS(...) also returns 8 | % the set of selected nodes in the original graph for each subgraph. 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | 13 | % Copyright Benjamin Girault, University of Sourthern California, Los 14 | % Angeles, California, USA (2019) 15 | % 16 | % benjamin.girault@usc.edu 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function [graphs, nodes] = grasp_maximally_connected_subgraphs(graph) 48 | % Load the matlab-bgl toolbox for 'components' 49 | grasp_start_opt_3rd_party('MatlabBGL'); 50 | 51 | % Find the connected component 52 | [conn_comps, sizes] = components(sparse(graph.A)); 53 | 54 | % Sort by decreasing size 55 | [~, IX] = sort(sizes, 'descend'); 56 | 57 | % Build the graph by decreasing size 58 | graphs(numel(IX)) = graph; 59 | nodes = cell(numel(IX), 1); 60 | for i = 1:numel(IX) 61 | nodes{i} = find(conn_comps == IX(i)); 62 | grasp_subgraph(graph, nodes{i}) 63 | graphs(i) 64 | graphs(i) = grasp_subgraph(graph, nodes{i}); 65 | end 66 | 67 | % [~, largest_cc] = max(sizes); 68 | % nodes = find(conn_comps == largest_cc); 69 | % 70 | % % Select only the nodes of that component 71 | % graph = grasp_subgraph(graph, nodes); 72 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_nb_nodes.m: -------------------------------------------------------------------------------- 1 | %Number of nodes in a graph. 2 | % 3 | % N = GRASP_NB_NODES(graph) returns N = |V| for the provided graph. 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | 8 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 9 | % Inria, FRANCE (2015-11-01) 10 | % 11 | % benjamin.girault@ens-lyon.fr 12 | % 13 | % This software is a computer program whose purpose is to provide a Matlab 14 | % / Octave toolbox for handling and displaying graph signals. 15 | % 16 | % This software is governed by the CeCILL license under French law and 17 | % abiding by the rules of distribution of free software. You can use, 18 | % modify and/ or redistribute the software under the terms of the CeCILL 19 | % license as circulated by CEA, CNRS and INRIA at the following URL 20 | % "http://www.cecill.info". 21 | % 22 | % As a counterpart to the access to the source code and rights to copy, 23 | % modify and redistribute granted by the license, users are provided only 24 | % with a limited warranty and the software's author, the holder of the 25 | % economic rights, and the successive licensors have only limited 26 | % liability. 27 | % 28 | % In this respect, the user's attention is drawn to the risks associated 29 | % with loading, using, modifying and/or developing or reproducing the 30 | % software by the user in light of its specific status of free software, 31 | % that may mean that it is complicated to manipulate, and that also 32 | % therefore means that it is reserved for developers and experienced 33 | % professionals having in-depth computer knowledge. Users are therefore 34 | % encouraged to load and test the software's suitability as regards their 35 | % requirements in conditions enabling the security of their systems and/or 36 | % data to be ensured and, more generally, to use and operate it in the 37 | % same conditions as regards security. 38 | % 39 | % The fact that you are presently reading this means that you have had 40 | % knowledge of the CeCILL license and that you accept its terms. 41 | 42 | function N = grasp_nb_nodes(graph) 43 | N = size(graph.A, 1); 44 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_struct.m: -------------------------------------------------------------------------------- 1 | %Defines and returns an empty graph structure. 2 | % 3 | % GRASP_STRUCT() 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-2016) 11 | % Copyright Benjamin Girault, University of Sourthern California, Los 12 | % Angeles, California, USA (2018-2019) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % benjamin.girault@usc.edu 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function g = grasp_struct 47 | g.A = 0; % Adjacency matrix. g.A(j,i) is the weight of the edge from i to j 48 | g.A_layout = 0; % Adjacency matrix to plot 49 | g.layout = 0; % Graph layout (2D or 3D) 50 | g.distances = 0; % Matrix of distances between any pair of nodes 51 | g.node_names = {}; % Cell of strings for the names of nodes 52 | g.M = 0; % Matrix of the graph variation operator (e.g. the Laplacian) 53 | g.Q = 0; % Matrix of the graph signal inner product (e.g. identity) 54 | g.Z = 0; % Matrix of the fundamental matrix of the graph 55 | g.fourier_version = 'n.a.'; % Version of the graph Fourier transform used to get eigvals, F and Finv 56 | g.eigvals = 0; % Graph frequencies of the graph 57 | g.F = 0; % Fourier matrix 58 | g.Finv = 0; % Inverse Fourier matrix 59 | g.T = 0; % Translation operator 60 | g.background = ''; % Background image file path 61 | g.show_graph_options = struct(); % Default options for grasp_show_graph 62 | end 63 | -------------------------------------------------------------------------------- /Graphs/Tools/grasp_subgraph.m: -------------------------------------------------------------------------------- 1 | %Computes a subgraph. 2 | % 3 | %NOTE: this function only updates the standard fields of the graph 4 | %structure (see GRASP_STRUCT). 5 | % 6 | % g = GRASP_SUBGRAPH(g, vertex_set) remove the vertex not in vertex_set 7 | % from the graph g. 8 | % 9 | % [..., mapping] = GRASP_SUBGRAPH(...) also outputs the mapping from the 10 | % old vertex index to the new vertex index (0 if not included). 11 | % 12 | % Authors: 13 | % - Benjamin Girault 14 | 15 | % Copyright Benjamin Girault, University of Sourthern California, Los 16 | % Angeles, California, USA (2017-2018) 17 | % 18 | % benjamin.girault@usc.edu 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function [g, mapping] = grasp_subgraph(g, vertex_set) 50 | Nold = grasp_nb_nodes(g); 51 | Nnew = numel(vertex_set); 52 | 53 | mapping = zeros(Nold, 1); 54 | mapping(vertex_set) = (1:Nnew)'; 55 | 56 | if numel(g.A) > 1 57 | g.A = g.A(vertex_set, vertex_set); 58 | end 59 | if numel(g.A_layout) > 1 60 | g.A_layout = g.A_layout(vertex_set, vertex_set); 61 | end 62 | if numel(g.layout) > 1 63 | g.layout = g.layout(vertex_set, :); 64 | end 65 | if numel(g.distances) > 1 66 | g.distances = g.distances(vertex_set, vertex_set); 67 | end 68 | if numel(g.node_names) > 0 69 | g.node_names = g.node_names(vertex_set); 70 | end 71 | g.M = 0; 72 | g.Q = 0; 73 | g.Z = 0; 74 | g.fourier_version = 'n.a.'; % Matrix used for the Fourier transform 75 | g.eigvals = 0; % Eigenvalues of the graph 76 | g.F = 0; % Fourier matrix 77 | g.Finv = 0; % Invert Fourier matrix 78 | g.T = 0; % Translation operator 79 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_symetrise_unweighted.m: -------------------------------------------------------------------------------- 1 | %Symetrises an unweighted graph. 2 | % 3 | % graph = GRASP_SYMETRISE_UNWEIGHTED(graph) symetrises the unweighted 4 | % graph so as to keep the graph unweighted. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_symetrise_unweighted(graph) 44 | graph.A = graph.A + (graph.A' - graph.A > 0); 45 | 46 | % Remove any irrelevant data remaining 47 | graph.L = 0; 48 | graph.eigvals = 0; 49 | graph.F = 0; 50 | graph.Finv = 0; 51 | graph.T = 0; 52 | end -------------------------------------------------------------------------------- /Graphs/Tools/grasp_voronoi_areas.m: -------------------------------------------------------------------------------- 1 | %Given a graph layout, compute the Voronoi diagram, and the area of each 2 | %cell of the diagram. 3 | % 4 | % VA = GRASP_VORONOI_AREAS(graph) compute for each vertex the area of 5 | % its Voronoi cell. 6 | % 7 | % GRASP_VORONOI_AREAS(..., diagram_ax_handle) show the Voronoi diagram 8 | % on the axes provided. 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | 13 | % Copyright Benjamin Girault, University of Southern California, USA 14 | % (2017-2018). 15 | % 16 | % benjamin.girault@usc.edu 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function VA = grasp_voronoi_areas(graph, diagram_ax_handle) 48 | % Trick: for each vertex, add four vertices mirrored by one of the 49 | % boundary edges, thus ensuring that each cell is within the boundary 50 | coords = graph.layout; 51 | N = size(coords, 1); 52 | coords(5 * N, 2) = 0; 53 | for i = 1:N 54 | coords(N + i, :) = [-coords(i, 1) coords(i, 2)]; 55 | coords(2 * N + i, :) = [coords(i, 1) -coords(i, 2)]; 56 | coords(3 * N + i, :) = [20 - coords(i, 1) coords(i, 2)]; 57 | coords(4 * N + i, :) = [coords(i, 1) 20 - coords(i, 2)]; 58 | end 59 | 60 | % Voronoi Cells 61 | [voro_verts, voro_cells] = voronoin(coords); 62 | 63 | % Plot these cells 64 | if nargin > 1 && diagram_ax_handle ~= 0 65 | plot(diagram_ax_handle, graph.layout(:, 1), graph.layout(:, 2), 'xr'); 66 | hold on 67 | for i = 1:N 68 | plot(diagram_ax_handle,... 69 | [voro_verts(voro_cells{i}, 1) ; voro_verts(voro_cells{i}(1), 1)]',... 70 | [voro_verts(voro_cells{i}, 2) ; voro_verts(voro_cells{i}(1), 2)]',... 71 | '-b'); 72 | end 73 | hold off 74 | xlim(diagram_ax_handle, [-2 12]); 75 | ylim(diagram_ax_handle, [-2 12]); 76 | end 77 | 78 | % Compute the Voronoi areas 79 | VA = cellfun(@(c) polyarea(voro_verts(c, 1), voro_verts(c, 2)), voro_cells(1:N)); 80 | end -------------------------------------------------------------------------------- /Graphs/grasp_clique.m: -------------------------------------------------------------------------------- 1 | %Constructs a complete graph. 2 | % 3 | % graph = GRASP_CLIQUE(N) returns a complete graph (clique) with N 4 | % nodes. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_clique(N) 44 | graph = grasp_struct; 45 | graph.A = ones(N) - eye(N); 46 | graph.layout = (0:(N - 1))'; 47 | graph.layout = exp(2 * pi * 1i * graph.layout / N); 48 | graph.layout = 5 * ([real(graph.layout) imag(graph.layout)] + 1); 49 | end -------------------------------------------------------------------------------- /Graphs/grasp_comete.m: -------------------------------------------------------------------------------- 1 | %Construct a comete 2 | % 3 | % graph = GRASP_COMETE(Nqueue, Nhead) returns a comete graph with a head 4 | % of Nhead nodes in a clique connected to a non directed path of 5 | % Nqueue nodes. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function graph = grasp_comete(Nqueue, Nhead) 45 | graph = grasp_struct; 46 | 47 | graph_queue = grasp_non_directed_path(Nqueue); 48 | graph_head = grasp_clique(Nhead); 49 | 50 | graph.A = graph_queue.A; 51 | graph.A(Nqueue + (1:Nhead), Nqueue + (1:Nhead)) = graph_head.A; 52 | graph.A(Nqueue, Nqueue + 1) = 1; 53 | graph.A(Nqueue + 1, Nqueue) = 1; 54 | 55 | graph.layout(Nqueue + Nhead, 2) = 0; 56 | graph.layout(1:Nqueue, 1) = graph_queue.layout(:, 1) * 0.8; 57 | graph.layout(1:Nqueue, 2) = graph_queue.layout(:, 2); 58 | graph.layout(Nqueue + (1:Nhead), 1) = 8 + (10 - graph_head.layout(:, 1)) * 0.2; 59 | graph.layout(Nqueue + (1:Nhead), 2) = 5 + (graph_head.layout(:, 2) - 5) * 0.2; 60 | end -------------------------------------------------------------------------------- /Graphs/grasp_complete.m: -------------------------------------------------------------------------------- 1 | %Constructs a complete graph 2 | % 3 | % graph = GRASP_COMPLETE(N) constructs a complete graph with N nodes. 4 | % 5 | % options.build_layout: true if the graph should include a layout 6 | % (default: true). Nodes will be aranged on a circle. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, University of Southern California, USA 13 | % (2020). 14 | % Copyright Benjamin Girault, École Nationale de la Statistique et de 15 | % l'Analyse de l'Information, Bruz, FRANCE (2020-2021) 16 | % 17 | % benjamin.girault@usc.edu 18 | % benjamin.girault@ensai.fr 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function graph = grasp_complete(N, varargin) 50 | %% Parameters 51 | default_param = struct(... 52 | 'build_layout', true); 53 | if isempty(varargin) 54 | options = struct; 55 | elseif length(varargin) > 1 56 | options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 57 | else 58 | options = varargin{1}; 59 | end 60 | options = grasp_merge_structs(default_param, options); 61 | 62 | %% Build the graph 63 | graph = grasp_struct; 64 | graph.A = ones(N) - eye(N); 65 | 66 | if options.build_layout 67 | z = 0.9 * exp(1i * 2 * pi * (0:(N - 1)) / N); 68 | graph.layout = [real(z') imag(z')]; 69 | graph.layout = 10 * (graph.layout + 1) / 2; 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /Graphs/grasp_directed_cycle.m: -------------------------------------------------------------------------------- 1 | %Constructs a directed cycle 2 | % 3 | % graph = GRASP_DIRECTED_CYCLE(N) returns the graph structure of a 4 | % directed cycle of length N 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_directed_cycle(N) 44 | graph = grasp_struct; 45 | graph.A(N, N) = 0; 46 | 47 | graph.A(1:N - 1, 2:N) = eye(N - 1); 48 | graph.A(N, 1) = 1; 49 | 50 | graph.A = sparse(graph.A); 51 | 52 | z = 0.9 * exp(1i * 2 * pi * (0:(N - 1)) / N); 53 | graph.layout = [real(z') imag(z')]; 54 | graph.layout = 10 * (graph.layout + 1) / 2; 55 | end -------------------------------------------------------------------------------- /Graphs/grasp_directed_grid.m: -------------------------------------------------------------------------------- 1 | %Construct a grid. 2 | % 3 | % graph = GRASP_DIRECTED_GRID(N) constructs a grid of NxN, with node 4 | % (i,j) having id 1 + N * i + j. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_directed_grid(N) 44 | %% Size of the new graph 45 | NA = N * N; 46 | 47 | %% Initialization 48 | graph = grasp_struct; 49 | graph.A(NA, NA) = 0; 50 | graph.layout(NA, 2) = 0; 51 | 52 | %% Grid ((0,0) => top left) 53 | for i = 0:(N - 1) 54 | for j = 0:(N - 1) 55 | cur = 1 + N * i + j; 56 | below = 1 + N * (i + 1) + j; 57 | right = 1 + N * i + (j + 1); 58 | if i < N - 1 59 | graph.A(cur, below) = 1; 60 | end 61 | if j < N - 1 62 | graph.A(cur, right) = 1; 63 | end 64 | 65 | graph.layout(cur, 1) = 10 * (i + 1/2) / N; 66 | graph.layout(cur, 2) = 10 * (j + 1/2) / N; 67 | end 68 | end 69 | 70 | %% Sparsify 71 | graph.A = sparse(graph.A); 72 | end -------------------------------------------------------------------------------- /Graphs/grasp_directed_path.m: -------------------------------------------------------------------------------- 1 | %Constructs an directed path. 2 | % 3 | % graph = GRASP_DIRECTED_PATH(N) returns the graph structure of a 4 | % directed path of length N. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_directed_path(N) 44 | graph = grasp_struct; 45 | graph.A(N, N) = 0; 46 | 47 | graph.A(1:N - 1, 2:N) = eye(N - 1); 48 | 49 | graph.A = sparse(graph.A); 50 | 51 | graph.layout = [(1:N)' / (N + 1) * 10 5 * ones(N, 1)]; 52 | end -------------------------------------------------------------------------------- /Graphs/grasp_directed_torus.m: -------------------------------------------------------------------------------- 1 | %sConstruct a directed torus. 2 | % 3 | % graph = GRASP_DIRECTED_TORUS(N) constructs an directed torus of NxN, 4 | % with node (i,j) having id 1 + N * i + j. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015) 12 | % Copyright Benjamin Girault, University of Sourthern California, Los 13 | % Angeles, California, USA (2016) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % benjamin.girault@usc.edu 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function graph = grasp_directed_torus(N, M) 48 | %% Size of the new graph 49 | if nargin == 1 50 | M = N; 51 | end 52 | NA = N * M; 53 | 54 | %% Initialization 55 | graph = grasp_struct; 56 | graph.A(NA, NA) = 0; 57 | graph.layout(NA, 2) = 0; 58 | 59 | %% Grid ((0,0) => top left) 60 | for i = 0:(N - 1) 61 | for j = 0:(M - 1) 62 | cur = 1 + M * i + j; 63 | below = 1 + M * (i + 1) + j; 64 | right = 1 + M * i + (j + 1); 65 | if i < N - 1 66 | graph.A(cur, below) = 1; 67 | else 68 | graph.A(cur, 1 + j) = 1; 69 | end 70 | if j < M - 1 71 | graph.A(cur, right) = 1; 72 | else 73 | graph.A(cur, 1 + M * i) = 1; 74 | end 75 | 76 | graph.layout(cur, 1) = 10 * (i + 1/2) / N; 77 | graph.layout(cur, 2) = 10 * (j + 1/2) / M; 78 | end 79 | end 80 | 81 | %% Sparsify 82 | graph.A = sparse(graph.A); 83 | end -------------------------------------------------------------------------------- /Graphs/grasp_non_directed_cycle.m: -------------------------------------------------------------------------------- 1 | %Constructs a non directed cycle. 2 | % 3 | % graph = GRASP_NON_DIRECTED_CYCLE(N) returns a graph structure for the 4 | % non directed cycle of length N. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_non_directed_cycle(N) 44 | graph = grasp_directed_cycle(N); 45 | graph = grasp_symetrise_unweighted(graph); 46 | end -------------------------------------------------------------------------------- /Graphs/grasp_non_directed_grid.m: -------------------------------------------------------------------------------- 1 | %Construct a non directed grid. 2 | % 3 | % graph = GRASP_NON_DIRECTED_GRID(N) constructs a grid of NxN, with node 4 | % (i,j) having id 1 + N * i + j. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_non_directed_grid(N) 44 | graph = grasp_directed_grid(N); 45 | graph = grasp_symetrise_unweighted(graph); 46 | end -------------------------------------------------------------------------------- /Graphs/grasp_non_directed_path.m: -------------------------------------------------------------------------------- 1 | %Constructs a non directed path. 2 | % 3 | % graph = GRASP_NON_DIRECTED_PATH(N) returns a graph structure for the 4 | % non directed path of length N. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_non_directed_path(N) 44 | graph = grasp_directed_path(N); 45 | graph = grasp_symetrise_unweighted(graph); 46 | end -------------------------------------------------------------------------------- /Graphs/grasp_non_directed_torus.m: -------------------------------------------------------------------------------- 1 | %Constructs a non directed torus. 2 | % 3 | % graph = GRASP_NON_DIRECTED_TORUS(N) constructs a torus of NxN, with 4 | % node (i,j) having id 1 + N * i + j. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_non_directed_torus(N, M) 44 | if nargin == 1 45 | M = N; 46 | end 47 | graph = grasp_directed_torus(N, M); 48 | graph = grasp_symetrise_unweighted(graph); 49 | end -------------------------------------------------------------------------------- /Graphs/grasp_plane_knn.m: -------------------------------------------------------------------------------- 1 | %Constructs a graph of k the nearest neighbors where nodes are sampled on 2 | %the 2D plane. 3 | % 4 | % graph = GRASP_PLANE_KNN(N, k) returns a graph constructed from nodes 5 | % uniformly sampled on the plane and connected using the k nearest 6 | % neighbors method. The adjacency matrix is weighted by the Gaussian 7 | % kernel of the distance. 8 | % 9 | % GRASP_PLANE_KNN(..., options) optional parameters: 10 | % 11 | % options.directed: true if graph should stay directed (default: false) 12 | % options.sigma: sigma^2 in the Gaussian kernel (default: 1) 13 | % 14 | % Authors: 15 | % - Benjamin Girault 16 | 17 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 18 | % Inria, FRANCE (2015-11-01) 19 | % 20 | % benjamin.girault@ens-lyon.fr 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function graph = grasp_plane_knn(N, k, varargin) 52 | %% Parameters 53 | default_param = struct(... 54 | 'directed', false,... 55 | 'sigma', 1); 56 | if nargin == 2 57 | options = struct; 58 | elseif nargin > 3 59 | options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 60 | else 61 | options = varargin{1}; 62 | end 63 | options = grasp_merge_structs(default_param, options); 64 | 65 | %% Intializations 66 | graph = grasp_struct; 67 | 68 | %% Random nodes on the plane 69 | graph.layout = 10 * rand(N, 2); 70 | 71 | %% Distances 72 | graph.distances = grasp_distances_layout(graph); 73 | 74 | %% Compute the k nearest neighbors 75 | graph.A = grasp_adjacency_gaussian(graph, options.sigma); 76 | graph.A = grasp_adjacency_knn(graph, k); 77 | 78 | %% Symetrise ? 79 | if ~options.directed 80 | graph.A = max(graph.A, graph.A'); 81 | end 82 | end -------------------------------------------------------------------------------- /Graphs/grasp_plane_rnd_grad_samp.m: -------------------------------------------------------------------------------- 1 | %Constructs a complete graph where nodes are non uniformly sampled on the 2 | %2D plane and weighted by a Gaussian kernel. 3 | % 4 | % graph = GRASP_PLANE_RND_GRAD_SAMP(N) returns a graph constructed from N 5 | % nodes non uniformly sampled on the plane, using a gradient. The 6 | % adjacency matrix is weighted by a Gaussian kernel of the distance with 7 | % parameter sigma = 1. Highest density is in the center. 8 | % 9 | % GRASP_PLANE_RND(..., options) optional parameters: 10 | % 11 | % options.directed: true if graph should stay directed (default: false) 12 | % options.sigma: sigma^2 in the Gaussian kernel (default: 1) 13 | % 14 | % Authors: 15 | % - Benjamin Girault 16 | 17 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 18 | % Inria, FRANCE (2015-11-01) 19 | % 20 | % benjamin.girault@ens-lyon.fr 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function graph = grasp_plane_rnd_grad_samp(N, varargin) 52 | %% Parameters 53 | default_param = struct(... 54 | 'directed', false,... 55 | 'sigma', 1); 56 | if nargin == 1 57 | options = struct; 58 | elseif nargin > 2 59 | options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 60 | else 61 | options = varargin{1}; 62 | end 63 | options = grasp_merge_structs(default_param, options); 64 | 65 | %% Intializations 66 | graph = grasp_struct; 67 | 68 | %% Random nodes on the plane 69 | c = 0.3; 70 | f = @(x) c * x .^ 3 + (1 - c) * x; 71 | z = (f(2 * rand(N, 1) - 1) * 5) .* exp(1i .* rand(N, 1) * 2 * pi); 72 | graph.layout = [real(z) imag(z)] + 5; 73 | 74 | %% Distances 75 | graph.distances = grasp_distances_layout(graph); 76 | 77 | %% Compute the Gaussian kernel. 78 | graph.A = grasp_adjacency_gaussian(graph, options.sigma); 79 | 80 | %% Symetrise ? 81 | if ~options.directed 82 | graph.A = max(graph.A, graph.A'); 83 | end 84 | end -------------------------------------------------------------------------------- /Graphs/grasp_random_regular.m: -------------------------------------------------------------------------------- 1 | %Construct a random regular graph. 2 | % 3 | % graph = GRASP_RANDOM_REGULAR(N, k) returns a random regular graph with 4 | % degree k and N nodes. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function graph = grasp_random_regular(N, k) 44 | %% Initializations 45 | graph = grasp_struct; 46 | 47 | %% Unbiased random generation of such a graph 48 | while true 49 | v = floor((randperm(N * k) - 1) / k + 1); 50 | A = zeros(N); 51 | for i = 1:2:(N * k - 1) 52 | A(v(i), v(i + 1)) = A(v(i), v(i + 1)) + 1; 53 | end 54 | A = A + A'; 55 | if sum(diag(A)) == 0 && max(A(:)) <= 1 56 | graph.A = A; 57 | break; 58 | end 59 | end 60 | 61 | %% Random layout 62 | graph.layout = grasp_layout(graph); 63 | end -------------------------------------------------------------------------------- /Graphs/grasp_watts_strogatz.m: -------------------------------------------------------------------------------- 1 | %Constructs a graph from the Watts-Strogatz model. 2 | % 3 | %Ref: https://doi.org/10.1038/30918 4 | % 5 | % graph = GRASP_WATTS_STROGATZ(N, K, beta) constructs a watts-stogatz 6 | % graph with N nodes, average degree K and with probability beta of 7 | % rewiring. 8 | % 9 | % Authors: 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-11-01) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function graph = grasp_watts_strogatz(N, K, beta) 47 | %% Initialization 48 | graph = grasp_struct; 49 | graph.A(N, N) = 0; 50 | nbRightNeighbors = floor(K / 2); 51 | 52 | %% Add neighbors 53 | for i = 1:N 54 | for j = (i + 1):(i + nbRightNeighbors) 55 | k = mod(j - 1, N) + 1; 56 | graph.A(i, k) = 1; 57 | graph.A(k, i) = 1; 58 | end 59 | end 60 | 61 | %% Rewiring 62 | for dj = 1:nbRightNeighbors 63 | for i = 1:N 64 | j = mod(i + dj - 1, N) + 1; 65 | if graph.A(i, j) > 0 && rand(1) < beta 66 | k = randi([1 N]); 67 | while k == i || graph.A(i, k) > 0 68 | k = randi([1 N]); 69 | end 70 | graph.A(i, j) = 0; 71 | graph.A(j, i) = 0; 72 | graph.A(i, k) = 1; 73 | graph.A(k, i) = 1; 74 | end 75 | end 76 | end 77 | 78 | %% Layout 79 | tmp = grasp_directed_cycle(N); 80 | graph.layout = tmp.layout; 81 | end -------------------------------------------------------------------------------- /Graphs/minnesota_coarse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/Graphs/minnesota_coarse.png -------------------------------------------------------------------------------- /Graphs/minnesota_fine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/Graphs/minnesota_fine.png -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/LICENCE.txt -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/LICENSE.txt -------------------------------------------------------------------------------- /LaTeX/tikzbabel.sty: -------------------------------------------------------------------------------- 1 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 2 | % Inria, FRANCE (2015-11-01) 3 | % 4 | % benjamin.girault@ens-lyon.fr 5 | % 6 | % This software is a computer program whose purpose is to provide a Matlab 7 | % / Octave toolbox for handling and displaying graph signals. 8 | % 9 | % This software is governed by the CeCILL license under French law and 10 | % abiding by the rules of distribution of free software. You can use, 11 | % modify and/ or redistribute the software under the terms of the CeCILL 12 | % license as circulated by CEA, CNRS and INRIA at the following URL 13 | % "http://www.cecill.info". 14 | % 15 | % As a counterpart to the access to the source code and rights to copy, 16 | % modify and redistribute granted by the license, users are provided only 17 | % with a limited warranty and the software's author, the holder of the 18 | % economic rights, and the successive licensors have only limited 19 | % liability. 20 | % 21 | % In this respect, the user's attention is drawn to the risks associated 22 | % with loading, using, modifying and/or developing or reproducing the 23 | % software by the user in light of its specific status of free software, 24 | % that may mean that it is complicated to manipulate, and that also 25 | % therefore means that it is reserved for developers and experienced 26 | % professionals having in-depth computer knowledge. Users are therefore 27 | % encouraged to load and test the software's suitability as regards their 28 | % requirements in conditions enabling the security of their systems and/or 29 | % data to be ensured and, more generally, to use and operate it in the 30 | % same conditions as regards security. 31 | % 32 | % The fact that you are presently reading this means that you have had 33 | % knowledge of the CeCILL license and that you accept its terms. 34 | 35 | \NeedsTeXFormat{LaTeX2e}[1994/06/01] 36 | \ProvidesPackage{tikzbabel}[2015/11/01] 37 | 38 | \RequirePackage{ifthen} 39 | \newcommand{\@babel@loaded}{0} 40 | \AtBeginDocument{\@ifpackageloaded{babel} 41 | {\renewcommand{\@babel@loaded}{1}} 42 | {\renewcommand{\@babel@loaded}{0}} 43 | } -------------------------------------------------------------------------------- /Operators/grasp_build_translations_epfl.m: -------------------------------------------------------------------------------- 1 | %Builds all epfl translation for a given graph and stores them in the 2 | %field Tepfl. 3 | % 4 | % graph = GRASP_BUILD_TRANSLATIONS_EPFL(graph) adds to graph the field 5 | % Tepfl which is a cell with all epfl translations. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function graph = grasp_build_translations_epfl(graph) 45 | N = grasp_nb_nodes(graph); 46 | graph.Tepfl = cellfun(@(i) grasp_generalized_translation(graph, i), num2cell(1:N), 'UniformOutput', false); 47 | end -------------------------------------------------------------------------------- /Operators/grasp_coherence.m: -------------------------------------------------------------------------------- 1 | %Computes the coherence of the graph (see Vertex-Frequency Analysis on 2 | %Graphs, Shuman et al. 2015). 3 | % 4 | % coherence = GRASP_COHERENCE(graph) returns the coherence of the Fourier 5 | % basis with respect to the canonical basis. 6 | % 7 | % [coherence, localisation] = GRASP_COHERENCE(graph) returns also the 8 | % vector localisation such that coherence = max(localisation) and 9 | % localisation(i) = max_l ||. 10 | % 11 | % Authors: 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015-11-01) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function [coherence, localisation] = grasp_coherence(graph) 49 | %% Localisation of each eigenvector 50 | localisation = max(abs(graph.Finv)); 51 | 52 | %% Coherence 53 | coherence = max(localisation); 54 | end -------------------------------------------------------------------------------- /Operators/grasp_convolution.m: -------------------------------------------------------------------------------- 1 | %Computes the generalized convolution of two signals [Shuman et al. 2013]. 2 | % 3 | % fg = GRASP_CONVOLUTION(graph, f, g) computes the convolution fg = f * g 4 | % such that \widehat{f * g} = \widehat{f} x \widehat{g}, x being the 5 | % pointwise multiplication. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % Copyright Benjamin Girault, University of Sourthern California, Los 14 | % Angeles, California, USA (2016-2018) 15 | % 16 | % benjamin.girault@ens-lyon.fr 17 | % benjamin.girault@usc.edu 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function fg = grasp_convolution(graph, f, g) 49 | if nargin == 2 50 | fg = grasp_fourier_inverse(graph, diag(grasp_fourier(graph, f))); 51 | else 52 | fhat = grasp_fourier(graph, f); 53 | ghat = grasp_fourier(graph, g); 54 | fg = grasp_fourier_inverse(graph, fhat .* ghat); 55 | end 56 | end -------------------------------------------------------------------------------- /Operators/grasp_dft_matrix.m: -------------------------------------------------------------------------------- 1 | %Computes the DFT matrix. 2 | % 3 | % A = GRASP_DFT_MATRIX(N) returns the DFT matrix A of order N. 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015) 11 | % Copyright Benjamin Girault, University of Sourthern California, Los 12 | % Angeles, California, USA (2016) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % benjamin.girault@usc.edu 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function A = grasp_dft_matrix(N) 47 | A = exp(1i * 2 * pi * kron((0:(N - 1))', ones(N, 1)') .* kron(ones(N, 1), 0:(N - 1)) / N); 48 | end -------------------------------------------------------------------------------- /Operators/grasp_filter_cheb.m: -------------------------------------------------------------------------------- 1 | %Defines and returns a Chebyshev polynomial approximation of a given 2 | %function. 3 | % 4 | % filter = GRASP_FILTER_CHEB(fun, order) computes the hebyshev polynomial 5 | % approximation of fun of the first kind of degree order on the 6 | % interval [0 2]. 7 | % 8 | % GRASP_FILTER_CHEB(..., options) optional parameters: 9 | % 10 | % options.interval: interval on which to compute the polynomial (default: 11 | % [0 2]). 12 | % 13 | % options.cheb_kind: first (1, default), or second (2) of Chebyshev 14 | % polynomial. 15 | % 16 | % Authors: 17 | % - Benjamin Girault 18 | 19 | % Copyright Benjamin Girault, University of Sourthern California, Los 20 | % Angeles, California, USA (2019) 21 | % 22 | % benjamin.girault@usc.edu 23 | % 24 | % This software is a computer program whose purpose is to provide a Matlab 25 | % / Octave toolbox for handling and displaying graph signals. 26 | % 27 | % This software is governed by the CeCILL license under French law and 28 | % abiding by the rules of distribution of free software. You can use, 29 | % modify and/ or redistribute the software under the terms of the CeCILL 30 | % license as circulated by CEA, CNRS and INRIA at the following URL 31 | % "http://www.cecill.info". 32 | % 33 | % As a counterpart to the access to the source code and rights to copy, 34 | % modify and redistribute granted by the license, users are provided only 35 | % with a limited warranty and the software's author, the holder of the 36 | % economic rights, and the successive licensors have only limited 37 | % liability. 38 | % 39 | % In this respect, the user's attention is drawn to the risks associated 40 | % with loading, using, modifying and/or developing or reproducing the 41 | % software by the user in light of its specific status of free software, 42 | % that may mean that it is complicated to manipulate, and that also 43 | % therefore means that it is reserved for developers and experienced 44 | % professionals having in-depth computer knowledge. Users are therefore 45 | % encouraged to load and test the software's suitability as regards their 46 | % requirements in conditions enabling the security of their systems and/or 47 | % data to be ensured and, more generally, to use and operate it in the 48 | % same conditions as regards security. 49 | % 50 | % The fact that you are presently reading this means that you have had 51 | % knowledge of the CeCILL license and that you accept its terms. 52 | 53 | function filter = grasp_filter_cheb(fun, order, varargin) 54 | %% Parameters 55 | default_param = struct(... 56 | 'interval', [0 2],... 57 | 'cheb_kind', 1,... 58 | 'chebfun_splitting', 0); 59 | if nargin == 2 60 | options = struct; 61 | elseif nargin > 3 62 | options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2); 63 | else 64 | options = varargin{1}; 65 | end 66 | options = grasp_merge_structs(default_param, options); 67 | 68 | %% Filter 69 | grasp_start_opt_3rd_party('chebfun'); 70 | 71 | filter.type = 'chebpoly'; 72 | filter.data.coeffs = chebcoeffs(chebfun(fun, options.interval, 'splitting', options.chebfun_splitting), order + 1, 'kind', options.cheb_kind); 73 | filter.data.interval = options.interval; 74 | filter.data.cheb_kind = options.cheb_kind; 75 | end -------------------------------------------------------------------------------- /Operators/grasp_filter_struct.m: -------------------------------------------------------------------------------- 1 | %Defines and returns an all-pass graph filter. 2 | % 3 | %This file serves as a reference for the filter structure. These are 4 | %filters that are independent from the graph structure. At the moment, 5 | %two fields are required: 6 | % - type: how is the filter defined? 7 | % - 'polynomial': polynomial of the fundamental matrix of the graph 8 | % - 'chebpoly': Chebyshev polynomial of the second kind of the 9 | % fundamental matrix of the graph 10 | % - 'kernel': function of the fundamental matrix of the graph, or 11 | % equivalently, function of the graph frequencies in the 12 | % spectral domain. 13 | % - 'convolution': graph signal to convolve a signal with 14 | % - 'matrix': for an arbitrary linear operator on graph signals 15 | % - data: actual implementation of the filter, depending on the type: 16 | % - polynomial: Matlab polynomial data structure 17 | % - chebpoly: structure with two fields: 18 | % - coeffs: vector of coefficients (first is lowest order) 19 | % - interval: interval on which the Chebyshev polynomial is defined 20 | % - cheb_kind: first (1) or second (2) kind of Chebyshev polynomial 21 | % - kernel: matlab function (see documentation of the operator @) 22 | % - convolution: graph signal 23 | % - matrix: NxN matrix (N being the graph size) 24 | % 25 | % filter = GRASP_FILTER_STRUCT() all_pass graph filter. 26 | % 27 | % Authors: 28 | % - Benjamin Girault 29 | 30 | % Copyright Benjamin Girault, University of Sourthern California, Los 31 | % Angeles, California, USA (2018) 32 | % 33 | % benjamin.girault@usc.edu 34 | % 35 | % This software is a computer program whose purpose is to provide a Matlab 36 | % / Octave toolbox for handling and displaying graph signals. 37 | % 38 | % This software is governed by the CeCILL license under French law and 39 | % abiding by the rules of distribution of free software. You can use, 40 | % modify and/ or redistribute the software under the terms of the CeCILL 41 | % license as circulated by CEA, CNRS and INRIA at the following URL 42 | % "http://www.cecill.info". 43 | % 44 | % As a counterpart to the access to the source code and rights to copy, 45 | % modify and redistribute granted by the license, users are provided only 46 | % with a limited warranty and the software's author, the holder of the 47 | % economic rights, and the successive licensors have only limited 48 | % liability. 49 | % 50 | % In this respect, the user's attention is drawn to the risks associated 51 | % with loading, using, modifying and/or developing or reproducing the 52 | % software by the user in light of its specific status of free software, 53 | % that may mean that it is complicated to manipulate, and that also 54 | % therefore means that it is reserved for developers and experienced 55 | % professionals having in-depth computer knowledge. Users are therefore 56 | % encouraged to load and test the software's suitability as regards their 57 | % requirements in conditions enabling the security of their systems and/or 58 | % data to be ensured and, more generally, to use and operate it in the 59 | % same conditions as regards security. 60 | % 61 | % The fact that you are presently reading this means that you have had 62 | % knowledge of the CeCILL license and that you accept its terms. 63 | 64 | function filter = grasp_filter_struct 65 | filter.type = 'polynomial'; 66 | filter.data = 1; 67 | end -------------------------------------------------------------------------------- /Operators/grasp_fourier.m: -------------------------------------------------------------------------------- 1 | %Performs the Fourier transform with respect to a graph. 2 | % 3 | % input_hat = GRASP_FOURIER(graph, input) if input is a vector, then 4 | % returns the fourier transform of input. If input is matrix, then input 5 | % is interpreted as an operator on signals on graph and input_hat is this 6 | % operator in the Fourier domain. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % 16 | % This software is a computer program whose purpose is to provide a Matlab 17 | % / Octave toolbox for handling and displaying graph signals. 18 | % 19 | % This software is governed by the CeCILL license under French law and 20 | % abiding by the rules of distribution of free software. You can use, 21 | % modify and/ or redistribute the software under the terms of the CeCILL 22 | % license as circulated by CEA, CNRS and INRIA at the following URL 23 | % "http://www.cecill.info". 24 | % 25 | % As a counterpart to the access to the source code and rights to copy, 26 | % modify and redistribute granted by the license, users are provided only 27 | % with a limited warranty and the software's author, the holder of the 28 | % economic rights, and the successive licensors have only limited 29 | % liability. 30 | % 31 | % In this respect, the user's attention is drawn to the risks associated 32 | % with loading, using, modifying and/or developing or reproducing the 33 | % software by the user in light of its specific status of free software, 34 | % that may mean that it is complicated to manipulate, and that also 35 | % therefore means that it is reserved for developers and experienced 36 | % professionals having in-depth computer knowledge. Users are therefore 37 | % encouraged to load and test the software's suitability as regards their 38 | % requirements in conditions enabling the security of their systems and/or 39 | % data to be ensured and, more generally, to use and operate it in the 40 | % same conditions as regards security. 41 | % 42 | % The fact that you are presently reading this means that you have had 43 | % knowledge of the CeCILL license and that you accept its terms. 44 | 45 | function input_hat = grasp_fourier(graph, input) 46 | if numel(graph.F) == 1 47 | error('Empty graph Fourier transform!'); 48 | end 49 | 50 | if isvector(input) 51 | input_hat = graph.F * input; 52 | else 53 | input_hat = graph.F * input * graph.Finv; 54 | end 55 | end -------------------------------------------------------------------------------- /Operators/grasp_fourier_inverse.m: -------------------------------------------------------------------------------- 1 | %Performs the inverse Fourier transform with respect to a graph. 2 | % 3 | % input_hat = GRASP_FOURIER_INVERSE(graph, input_hat) if input_hat is 4 | % a vector, then returns the inverse Fourier transform of input_hat. If 5 | % input_hat is matrix, then input_hat is interpreted as an operator on 6 | % signals on graph in the Fourier domain and input is this operator in 7 | % the direct domain. 8 | % 9 | % Authors: 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-11-01) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function input = grasp_fourier_inverse(graph, input_hat) 47 | if numel(graph.Finv) == 1 48 | error('Empty inverse graph Fourier transform!'); 49 | end 50 | 51 | if isvector(input_hat) 52 | input = graph.Finv * input_hat; 53 | else 54 | input = graph.Finv * input_hat * graph.F; 55 | end 56 | end -------------------------------------------------------------------------------- /Operators/grasp_generalized_modulation.m: -------------------------------------------------------------------------------- 1 | %Computes the modulation operators as defined by [Shuman et al. 2013]. The 2 | %resulting matrix operator M_l is such that 3 | %(M_l f)(i) = sqrt(N) f(i) chi_l(i). 4 | % 5 | % Ml = GRASP_GENERALIZED_MODULATION(graph, i) computes the l^th 6 | % modulation operator Ml, using the Fourier transform of graph. 7 | % 8 | % S = GRASP_GENERALIZED_MODULATION(..., f) applies the operator to f and 9 | % returns the modulated signal. 10 | % 11 | % Authors: 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015-11-01) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function Ml = grasp_generalized_modulation(graph, l, f) 49 | N = grasp_nb_nodes(graph); 50 | 51 | if nargin == 3 52 | Ml = sqrt(N) * graph.Finv(:, l) .* f; 53 | else 54 | Ml = sqrt(N) * diag(graph.Finv(:, l)); 55 | end 56 | end -------------------------------------------------------------------------------- /Operators/grasp_generalized_translation.m: -------------------------------------------------------------------------------- 1 | %Computes the translation operators as defined by [Shuman et al. 2013]. The 2 | %resulting matrix operator T_i is such that T_i f = sqrt(N) delta_i * f. 3 | % 4 | % Ti = GRASP_GENERALIZED_TRANSLATION(graph, i) computes the i^th 5 | % translation operator Ti, using the Fourier transform of graph. 6 | % 7 | % S = GRASP_GENERALIZED_TRANSLATION(..., f) applies the operator to f and 8 | % returns the translated signal. 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | 13 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 14 | % Inria, FRANCE (2015-11-01) 15 | % 16 | % benjamin.girault@ens-lyon.fr 17 | % 18 | % This software is a computer program whose purpose is to provide a Matlab 19 | % / Octave toolbox for handling and displaying graph signals. 20 | % 21 | % This software is governed by the CeCILL license under French law and 22 | % abiding by the rules of distribution of free software. You can use, 23 | % modify and/ or redistribute the software under the terms of the CeCILL 24 | % license as circulated by CEA, CNRS and INRIA at the following URL 25 | % "http://www.cecill.info". 26 | % 27 | % As a counterpart to the access to the source code and rights to copy, 28 | % modify and redistribute granted by the license, users are provided only 29 | % with a limited warranty and the software's author, the holder of the 30 | % economic rights, and the successive licensors have only limited 31 | % liability. 32 | % 33 | % In this respect, the user's attention is drawn to the risks associated 34 | % with loading, using, modifying and/or developing or reproducing the 35 | % software by the user in light of its specific status of free software, 36 | % that may mean that it is complicated to manipulate, and that also 37 | % therefore means that it is reserved for developers and experienced 38 | % professionals having in-depth computer knowledge. Users are therefore 39 | % encouraged to load and test the software's suitability as regards their 40 | % requirements in conditions enabling the security of their systems and/or 41 | % data to be ensured and, more generally, to use and operate it in the 42 | % same conditions as regards security. 43 | % 44 | % The fact that you are presently reading this means that you have had 45 | % knowledge of the CeCILL license and that you accept its terms. 46 | 47 | function Ti = grasp_generalized_translation(graph, i, f) 48 | N = grasp_nb_nodes(graph); 49 | 50 | if nargin == 3 51 | Ti = sqrt(N) * grasp_convolution(graph, f, grasp_delta(graph, i)); 52 | else 53 | Ti = sqrt(N) * grasp_fourier_inverse(graph, diag(graph.F(:, i))); 54 | end 55 | end -------------------------------------------------------------------------------- /Operators/grasp_isometrize_operator.m: -------------------------------------------------------------------------------- 1 | %Computes a isometric version of a convolutive operator [Girault et al. 2 | %2015, IEEE SPL]. 3 | % 4 | % H_iso = GRASP_ISOMETRIZE_OPERATOR(graph, H) returns an isometric 5 | % operator H_iso having as real part H on graph. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function H_iso = grasp_isometrize_operator(graph, H) 45 | if sum(sum(imag(H))) > 0 46 | error('Only possible for real matrices!'); 47 | end 48 | 49 | %% Computation 50 | H_hat = diag(grasp_fourier(graph, H)); 51 | if sum(abs(H_hat) > 1) ~= 0 52 | error('Only possible for |\hat{H}|<=1!'); 53 | end 54 | Omega_hat = acos(H_hat); 55 | H_iso = grasp_fourier_inverse(graph, diag(exp(1i * Omega_hat))); 56 | end -------------------------------------------------------------------------------- /Operators/grasp_semi_supervised.m: -------------------------------------------------------------------------------- 1 | %Computes a graph SSL kernel. [Avrachenkov et al., 2012: Generalized 2 | %Optimization Framework for Graph-based Semi-supervised Learning] 3 | % 4 | %Compared to [Girault et al., 2014: Semi-Supervised Learning for Graph to 5 | %Signal Mapping: a Graph Signal Wiener Filter Interpretation], alpha=2\mu. 6 | % 7 | %NOTE: This function is faster if the normalized Laplacian 8 | %eigendecomposition has been performed. 9 | % 10 | % H_SSL = GRASP_SEMI_SUPERVISED(g, sigma, mu) computes the SSL kernel of 11 | % the graph g with parameters sigma and mu. 12 | % 13 | % [H_SSL, H_SSL_hat] = GRASP_SEMI_SUPERVISED(...) also returns the 14 | % operator in the spectral domain. 15 | % 16 | % output = GRASP_SEMI_SUPERVISED(..., input) applies SSL to input 17 | % 18 | % Authors: 19 | % - Benjamin Girault 20 | 21 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 22 | % Inria, FRANCE (2015-11-01) 23 | % 24 | % benjamin.girault@ens-lyon.fr 25 | % 26 | % This software is a computer program whose purpose is to provide a Matlab 27 | % / Octave toolbox for handling and displaying graph signals. 28 | % 29 | % This software is governed by the CeCILL license under French law and 30 | % abiding by the rules of distribution of free software. You can use, 31 | % modify and/ or redistribute the software under the terms of the CeCILL 32 | % license as circulated by CEA, CNRS and INRIA at the following URL 33 | % "http://www.cecill.info". 34 | % 35 | % As a counterpart to the access to the source code and rights to copy, 36 | % modify and redistribute granted by the license, users are provided only 37 | % with a limited warranty and the software's author, the holder of the 38 | % economic rights, and the successive licensors have only limited 39 | % liability. 40 | % 41 | % In this respect, the user's attention is drawn to the risks associated 42 | % with loading, using, modifying and/or developing or reproducing the 43 | % software by the user in light of its specific status of free software, 44 | % that may mean that it is complicated to manipulate, and that also 45 | % therefore means that it is reserved for developers and experienced 46 | % professionals having in-depth computer knowledge. Users are therefore 47 | % encouraged to load and test the software's suitability as regards their 48 | % requirements in conditions enabling the security of their systems and/or 49 | % data to be ensured and, more generally, to use and operate it in the 50 | % same conditions as regards security. 51 | % 52 | % The fact that you are presently reading this means that you have had 53 | % knowledge of the CeCILL license and that you accept its terms. 54 | 55 | function [H_SSL, H_SSL_hat] = grasp_semi_supervised(g, sigma, mu, input) 56 | %% Rescaling (sigma) 57 | N = grasp_nb_nodes(g); 58 | D = grasp_degrees(g); 59 | Dsigma = sparse(diag( diag(D) .^ (0.5 - sigma) )); 60 | Dsigmainv = sparse(diag( diag(D) .^ (sigma - 0.5) )); 61 | 62 | %% Input / Output 63 | if nargin == 4 64 | input = Dsigmainv * input; 65 | output = (eye(N) + 2 / mu * grasp_laplacian_normalized(g)) \ input; 66 | output = Dsigma * output; 67 | H_SSL = output; 68 | return; 69 | end 70 | 71 | %% Initialization Fourier 72 | if ~isfield(g, 'fourier_version') || ~strcmp(g.fourier_version, 'normalized laplacian') 73 | g = grasp_eigendecomposition(g, 'matrix', 'norm_lapl'); 74 | end 75 | 76 | %% Classifier 77 | H_SSL_hat = sparse(diag( mu ./ (mu + 2 * g.eigvals) )); 78 | 79 | H_SSL = Dsigma * g.Finv * H_SSL_hat * g.F * Dsigmainv; 80 | end -------------------------------------------------------------------------------- /Operators/grasp_wft.m: -------------------------------------------------------------------------------- 1 | %Computes the windowed Fourier transform as defined by [Shuman et al. 2 | %2015]. 3 | % 4 | % wft = GRASP_WFT(graph, f) computes the wft matrix such that 5 | % wft(i, k) = with g_{i,k} the atom centered around node i 6 | % and at frequency lambda_k. The function g used to define the window is 7 | % a gaussian kernel of decay 3. 8 | % 9 | % GRASP_WFT(..., kernel_decay) use a gaussian window of prescribed decay. 10 | % 11 | % Authors: 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015-11-01) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function wft = grasp_wft(graph, f, kernel_decay) 49 | %% Initializations 50 | N = grasp_nb_nodes(graph); 51 | wft(N, N) = 0; 52 | if nargin == 2 53 | kernel_decay = 3; 54 | end 55 | kernel = grasp_heat_kernel(graph, kernel_decay); 56 | kernel = kernel / norm(kernel); 57 | 58 | %% Windowed Fourier Transform 59 | for i = 1:N 60 | window = grasp_generalized_translation(graph, i, kernel); 61 | for k = 1:N 62 | atom = grasp_generalized_modulation(graph, k, window); 63 | wft(i, k) = sum(f .* conj(atom)); 64 | end 65 | end 66 | end -------------------------------------------------------------------------------- /Plotting/grasp_animate_iterated_operator_gui.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/Plotting/grasp_animate_iterated_operator_gui.fig -------------------------------------------------------------------------------- /Plotting/grasp_gft_gui.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/Plotting/grasp_gft_gui.fig -------------------------------------------------------------------------------- /Plotting/grasp_open_figure_name.m: -------------------------------------------------------------------------------- 1 | %Opens a figure based on its name. 2 | % 3 | % hfig = GRASP_OPEN_FIGURE_NAME(name) opens the figure name closing all 4 | % other figures with the same name. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function hfig = grasp_open_figure_name(name) 44 | figures = findobj('type', 'figure', 'name', name); 45 | if numel(figures) > 0 46 | hfig = figure(figures(1)); 47 | close(figures(2:end)); 48 | else 49 | hfig = figure('Name', name, 'NumberTitle', 'off'); 50 | end 51 | end -------------------------------------------------------------------------------- /Plotting/grasp_scatter_update.m: -------------------------------------------------------------------------------- 1 | %Update the data associated to a scatter plot. When the scatter plot 2 | %represents nodes of a graph, this data is a graph signal. 3 | % 4 | % GRASP_SCATTER_UPDATE(ax, data) updates the axes ax corresponding to a 5 | % scatter plot and changes the 'CData' field. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 11 | % Inria, FRANCE (2015-11-01) 12 | % 13 | % benjamin.girault@ens-lyon.fr 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function grasp_scatter_update(ax, data) 45 | if strcmp(get(ax, 'Type'), 'surface') 46 | ix = 1:numel(data); 47 | if mod(numel(ix), 2) == 1 48 | ix(end + 1) = ix(end); 49 | end 50 | ix = reshape(ix, [], 2); 51 | set(ax, 'CData', data(ix)); 52 | else 53 | set(ax, 'CData', data); 54 | end 55 | end -------------------------------------------------------------------------------- /Plotting/grasp_show_matrix.m: -------------------------------------------------------------------------------- 1 | %Plots a matrix, with either regular square elements, or irregular ones. 2 | %IMSHOW is a faster alternative but requires extra work to scale the plot. 3 | % 4 | % GRASP_SHOW_MATRIX(axis_handle, M) Plots the matrix elements in the 5 | % plane. 6 | % 7 | % GRASP_SHOW_MATRIX(..., X, Y) uses X as the horizontal coordinates of 8 | % the vertical lines, and Y as the vertical coordinates of teh horizontal 9 | % lines (there are one more coordinate for each than there are rows / 10 | % columns). 11 | % 12 | % Authors: 13 | % - Benjamin Girault 14 | 15 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 16 | % Inria, FRANCE (2015-11-01) 17 | % 18 | % benjamin.girault@ens-lyon.fr 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function grasp_show_matrix(axis_handle, M, X, Y) 50 | %% Initializations 51 | nbcols = size(M, 2); 52 | nblines = size(M, 1); 53 | if nargin <= 2 54 | X = 0:nbcols; 55 | Y = 0:nblines; 56 | end 57 | 58 | polys_x(4, nbcols * nblines) = 0; 59 | polys_y(4, nbcols * nblines) = 0; 60 | 61 | %% Indices of the elements 62 | [ix, iy] = meshgrid(1:nbcols, 1:nblines); 63 | xs = ix(:); 64 | ys = iy(:); 65 | indices = (xs' - 1) * nblines + ys'; 66 | 67 | %% Polygones 68 | polys_x(1, :) = X(xs); 69 | polys_y(1, :) = Y(ys); 70 | polys_x(2, :) = X(xs + 1); 71 | polys_y(2, :) = Y(ys); 72 | polys_x(3, :) = X(xs + 1); 73 | polys_y(3, :) = Y(ys + 1); 74 | polys_x(4, :) = X(xs); 75 | polys_y(4, :) = Y(ys + 1); 76 | 77 | %% Plotting 78 | axes(axis_handle); 79 | xlim([min(X) max(X)]); 80 | ylim([min(Y) max(Y)]); 81 | set(axis_handle, 'ydir', 'reverse'); 82 | set(axis_handle, 'DataAspectRatio', [nblines nbcols 1]); 83 | hold(axis_handle, 'on'); 84 | patch(polys_x, polys_y, M(indices), 'EdgeColor', 'none'); 85 | hold(axis_handle, 'off'); 86 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GraSP: Graph Signal Processing and Visualization Toolbox 2 | 3 | This matlab toolbox is stable, but actively developped. Contributions are welcomed. 4 | 5 | ## Reference 6 | 7 | If you use the GraSP toolbox, please use the reference below: 8 | 9 | Benjamin Girault, Shrikanth S. Narayanan, Antonio Ortega, Paulo Gonçalves and Eric Fleury, 10 | "Grasp: A matlab toolbox for graph signal processing", 11 | 2017 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 12 | Pages: 6574 - 6575 13 | 14 | DOI: [10.1109/ICASSP.2017.8005300](https://doi.org/10.1109/ICASSP.2017.8005300) 15 | 16 | ### References for Additional Toolboxes 17 | 18 | A list of references for the active toolboxes (those activated by `grasp_start_opt_3rd_party`) are 19 | given by the function `grasp_bibliography`. For a detailed description of those, please refer to 20 | [the list of third party toolboxes](ThirdPartyToolboxes.md) 21 | 22 | ## Sources 23 | 24 | Official sources are specified in the [toolbox's website](https://www.grasp-toolbox.org/). 25 | 26 | The main repository is located in [Inria's Gitlab](https://gitlab.inria.fr/bgirault/grasp/), 27 | while the repository in [GitHub.com](https://github.com/GraSP-toolbox/GraSP) is a mirror. 28 | 29 | Bugreports will be addressed in both repositories. 30 | 31 | Note: This repository was originally hosted in [Inria's gForge](https://gforge.inria.fr/projects/grasp). 32 | 33 | ## Additional Toolboxes / Third Party Tools 34 | 35 | Several third party toolboxes are installed when `grasp_install` is run. If you want your toolbox added, 36 | please send me the URL of the toolbox, and the paper associated (if any). 37 | 38 | ## Author(s) 39 | 40 | The main author of GraSP is Benjamin Girault. The code has been developped 41 | during his PhD at École Normale Supérieure de Lyon, Lyon, FRANCE, with 42 | funding from *École Normale Supérieure de Lyon* and *Inria Rhône-Alpes*. 43 | Workon GraSP is continuing with funding from *University of Southern 44 | California*, Los Angeles, California, USA during his postdoctorate with 45 | Antonio Ortega and Shri Narayanan. 46 | 47 | To contact the author, please use Inria's Gitlab or GitHub interface or 48 | <firstname>.<lastname><a>usc<dot>edu. The ens-lyon.fr email referenced in 49 | the code is not active anymore. 50 | 51 | ## License 52 | 53 | This toolbox is distributed under the terms of the CeCILL license (see 54 | the LICENSE file for the english version of the license, and the LICENCE 55 | file for the french version). 56 | 57 | This license is GPL-compatible ([FSF](http://www.gnu.org/licenses/license-list.html)). 58 | 59 | ## Requirements 60 | - GraphViz 61 | 62 | ## Installation (for third party Matlab toolboxes) 63 | - run `grasp_install` 64 | 65 | ## Usage 66 | - run `grasp_start` 67 | - use it 68 | -------------------------------------------------------------------------------- /Signals/grasp_delta.m: -------------------------------------------------------------------------------- 1 | %Construct a delta on a graph. 2 | % 3 | % delta = GRASP_DELTA(graph, node) constructs the delta on node. 4 | % 5 | % ... = GRASP_DELTA(..., full_delta) whether the output should be a full 6 | % vector or a sparse vector (default: full). 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-2016) 14 | % Copyright Benjamin Girault, University of Sourthern California, Los 15 | % Angeles, California, USA (2018) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % benjamin.girault@usc.edu 19 | % 20 | % This software is a computer program whose purpose is to provide a Matlab 21 | % / Octave toolbox for handling and displaying graph signals. 22 | % 23 | % This software is governed by the CeCILL license under French law and 24 | % abiding by the rules of distribution of free software. You can use, 25 | % modify and/ or redistribute the software under the terms of the CeCILL 26 | % license as circulated by CEA, CNRS and INRIA at the following URL 27 | % "http://www.cecill.info". 28 | % 29 | % As a counterpart to the access to the source code and rights to copy, 30 | % modify and redistribute granted by the license, users are provided only 31 | % with a limited warranty and the software's author, the holder of the 32 | % economic rights, and the successive licensors have only limited 33 | % liability. 34 | % 35 | % In this respect, the user's attention is drawn to the risks associated 36 | % with loading, using, modifying and/or developing or reproducing the 37 | % software by the user in light of its specific status of free software, 38 | % that may mean that it is complicated to manipulate, and that also 39 | % therefore means that it is reserved for developers and experienced 40 | % professionals having in-depth computer knowledge. Users are therefore 41 | % encouraged to load and test the software's suitability as regards their 42 | % requirements in conditions enabling the security of their systems and/or 43 | % data to be ensured and, more generally, to use and operate it in the 44 | % same conditions as regards security. 45 | % 46 | % The fact that you are presently reading this means that you have had 47 | % knowledge of the CeCILL license and that you accept its terms. 48 | 49 | function delta = grasp_delta(graph, node, full_delta) 50 | if nargin == 2 || full_delta 51 | delta = full(sparse(node, 1, 1, grasp_nb_nodes(graph), 1)); 52 | else 53 | delta = sparse(node, 1, 1, grasp_nb_nodes(graph), 1); 54 | end 55 | end -------------------------------------------------------------------------------- /Signals/grasp_gaussian_signal_realization.m: -------------------------------------------------------------------------------- 1 | %Builds a graph signal with prescribed spectral correlation matrix and mean 2 | %and normal distribution on each node. 3 | % 4 | % signal = GRASP_GAUSSIAN_SIGNAL_REALIZATION(graph, mean, S) using the 5 | % spectral correlation matrix S, constructs a realization of the graph 6 | % signal normal variables. The signal has mean as its mean vector. 7 | % 8 | % signal = GRASP_GAUSSIAN_SIGNAL_REALIZATION(..., m) generate m 9 | % realizations. 10 | % 11 | % Authors: 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015-11-01) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function signal = grasp_gaussian_signal_realization(graph, mean, S, m) 49 | %% Preprocessing 50 | N = grasp_nb_nodes(graph); 51 | mean_hat = grasp_fourier(graph, mean); 52 | Cov_hat = S - mean_hat * mean_hat'; % Covariance 53 | 54 | if nargin == 3 55 | m = 1; 56 | end 57 | 58 | %% X 59 | X_hat = normrnd(0, 1, N, m); 60 | 61 | %% Y = LX 62 | try 63 | L = chol(Cov_hat, 'lower'); 64 | catch 65 | warning('off', 'MATLAB:sqrtm:SingularMatrix'); 66 | A = sqrtm(Cov_hat); 67 | if sum(sum(imag(A))) > 0 68 | error('Negative matrix!'); 69 | end 70 | [~, R] = qr(A); 71 | L = R'; 72 | end 73 | Y_hat = L * X_hat; 74 | 75 | %% Z = Y + mean 76 | signal = graph.Finv * Y_hat + kron(ones(1, m), mean); 77 | end -------------------------------------------------------------------------------- /Signals/grasp_heat_kernel.m: -------------------------------------------------------------------------------- 1 | %Constructs the heat kernel as defined in [Vertex-Frequency Analysis on 2 | %Graphs, Shuman et al.] 3 | % 4 | % heat = GRASP_HEAT_KERNEL(graph) returns a heat kernel with a decay of 5 | % 5. 6 | % 7 | % heat = GRASP_HEAT_KERNEL(..., decay) returns the heat kernel with the 8 | % prescribed decay. 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015) 16 | % Copyright Benjamin Girault, University of Sourthern California, Los 17 | % Angeles, California, USA (2016-2018) 18 | % 19 | % benjamin.girault@ens-lyon.fr 20 | % benjamin.girault@usc.edu 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function heat = grasp_heat_kernel(graph, decay) 52 | %% Checks 53 | if numel(graph.Finv) <= 1 54 | error('Missing Fourier inverse!'); 55 | end 56 | if numel(graph.eigvals) <= 1 57 | error('Missing eigenvalues!'); 58 | end 59 | 60 | if nargin == 1 61 | decay = 5; 62 | end 63 | 64 | %% Heat function 65 | heat = graph.Finv * exp(-decay * graph.eigvals); 66 | end -------------------------------------------------------------------------------- /Signals/grasp_signal_spread.m: -------------------------------------------------------------------------------- 1 | %Computes the graph spread of a signal (Agaskar & Lu, IEEE Info. Th. 2015) 2 | % 3 | % T = GRASP_SIGNAL_SPREAD(graph, signal) computes the graph spread of 4 | % signal on graph. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015-11-01) 11 | % 12 | % benjamin.girault@ens-lyon.fr 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function spread = grasp_signal_spread(graph, signal) 44 | %% Intialization 45 | if ~strcmp(graph.fourier_version, 'standard laplacian') && ~strcmp(graph.fourier_version, 'normalised laplacian') 46 | error('Error: The Fourier transform should be the result of the decomposition of a Laplacian matrix!'); 47 | end 48 | 49 | %% Matrix of distances in the graph 50 | distances = all_shortest_paths(sparse((graph.A ~= 0) + 1 -1)); 51 | 52 | %% Spread 53 | spread = 1 / norm(signal) ^ 2 * (distances .^ 2) * (abs(signal) .^ 2); 54 | spread = sqrt(min(spread)); 55 | end -------------------------------------------------------------------------------- /Signals/grasp_signal_spread_weighted.m: -------------------------------------------------------------------------------- 1 | %Computes the graph spread of a signal (Agaskar & Lu, IEEE Info. Th. 2015), 2 | %but using the distance matrix provided (Pasdeloup, Alami, Gripon, Rabbat, 3 | %EUSIPCO 2015). 4 | % 5 | % T = GRASP_SIGNAL_SPREAD_WEIGHTED(graph) computes the weighted graph 6 | % spread of signal on graph, using graph.distances (graph.distances(i,j) 7 | % is the distance between nodes i and j). 8 | % 9 | % Authors: 10 | % - Benjamin Girault 11 | 12 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 13 | % Inria, FRANCE (2015-11-01) 14 | % 15 | % benjamin.girault@ens-lyon.fr 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function spread = grasp_signal_spread_weighted(graph, signal) 47 | %% Intialization 48 | if ~strcmp(graph.fourier_version, 'standard laplacian') && ~strcmp(graph.fourier_version, 'normalised laplacian') 49 | error('Error: The Fourier transform should be the result of the decomposition of a Laplacian matrix!'); 50 | end 51 | 52 | %% Matrix of distances in the graph 53 | distances = graph.distances; 54 | 55 | %% Spread 56 | spread = 1 / norm(signal) ^ 2 * (distances .^ 2) * (abs(signal) .^ 2); 57 | spread = sqrt(min(spread)); 58 | end -------------------------------------------------------------------------------- /Stats/grasp_empirical_correlation.m: -------------------------------------------------------------------------------- 1 | %Computes the empirical correlation from several samples of a stochastic 2 | %signal. 3 | % 4 | % sigma = GRASP_EMPIRICAL_CORRELATION(signal) considering several realizations 5 | % of a stochastic signal (columns of signal), sigma is the empirical 6 | % correlation matrix of the signal. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % 16 | % This software is a computer program whose purpose is to provide a Matlab 17 | % / Octave toolbox for handling and displaying graph signals. 18 | % 19 | % This software is governed by the CeCILL license under French law and 20 | % abiding by the rules of distribution of free software. You can use, 21 | % modify and/ or redistribute the software under the terms of the CeCILL 22 | % license as circulated by CEA, CNRS and INRIA at the following URL 23 | % "http://www.cecill.info". 24 | % 25 | % As a counterpart to the access to the source code and rights to copy, 26 | % modify and redistribute granted by the license, users are provided only 27 | % with a limited warranty and the software's author, the holder of the 28 | % economic rights, and the successive licensors have only limited 29 | % liability. 30 | % 31 | % In this respect, the user's attention is drawn to the risks associated 32 | % with loading, using, modifying and/or developing or reproducing the 33 | % software by the user in light of its specific status of free software, 34 | % that may mean that it is complicated to manipulate, and that also 35 | % therefore means that it is reserved for developers and experienced 36 | % professionals having in-depth computer knowledge. Users are therefore 37 | % encouraged to load and test the software's suitability as regards their 38 | % requirements in conditions enabling the security of their systems and/or 39 | % data to be ensured and, more generally, to use and operate it in the 40 | % same conditions as regards security. 41 | % 42 | % The fact that you are presently reading this means that you have had 43 | % knowledge of the CeCILL license and that you accept its terms. 44 | 45 | function sigma = grasp_empirical_correlation(signal) 46 | sigma = cov(signal'); 47 | mu = mean(signal, 2); 48 | sigma = sigma + mu * mu'; 49 | end -------------------------------------------------------------------------------- /Stats/grasp_empirical_pearson_correlation.m: -------------------------------------------------------------------------------- 1 | %Computes the empirical Pearson correlation coefficient from several 2 | %samples of a stochastic signal. 3 | % 4 | % sigma = GRASP_EMPIRICAL_PEARSON_CORRELATION(signal) considering several 5 | % realizations of a stochastic signal (columns of signal), sigma is the 6 | % empirical Pearson correlation matrix of the signal. 7 | % 8 | % Authors: 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % 16 | % This software is a computer program whose purpose is to provide a Matlab 17 | % / Octave toolbox for handling and displaying graph signals. 18 | % 19 | % This software is governed by the CeCILL license under French law and 20 | % abiding by the rules of distribution of free software. You can use, 21 | % modify and/ or redistribute the software under the terms of the CeCILL 22 | % license as circulated by CEA, CNRS and INRIA at the following URL 23 | % "http://www.cecill.info". 24 | % 25 | % As a counterpart to the access to the source code and rights to copy, 26 | % modify and redistribute granted by the license, users are provided only 27 | % with a limited warranty and the software's author, the holder of the 28 | % economic rights, and the successive licensors have only limited 29 | % liability. 30 | % 31 | % In this respect, the user's attention is drawn to the risks associated 32 | % with loading, using, modifying and/or developing or reproducing the 33 | % software by the user in light of its specific status of free software, 34 | % that may mean that it is complicated to manipulate, and that also 35 | % therefore means that it is reserved for developers and experienced 36 | % professionals having in-depth computer knowledge. Users are therefore 37 | % encouraged to load and test the software's suitability as regards their 38 | % requirements in conditions enabling the security of their systems and/or 39 | % data to be ensured and, more generally, to use and operate it in the 40 | % same conditions as regards security. 41 | % 42 | % The fact that you are presently reading this means that you have had 43 | % knowledge of the CeCILL license and that you accept its terms. 44 | 45 | function [sigma, Pval] = grasp_empirical_pearson_correlation(signal) 46 | [sigma, Pval] = corrcoef(signal'); 47 | end -------------------------------------------------------------------------------- /Util/grasp_blueredcolormap.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraSP-toolbox/GraSP/e68c922fa189f5cbc304f8c599edd1b82761c88a/Util/grasp_blueredcolormap.mat -------------------------------------------------------------------------------- /Util/grasp_clean_pdf_export.m: -------------------------------------------------------------------------------- 1 | %Because exporting figures in PDF can be quite a mess... 2 | % 3 | % GRASP_CLEAN_PDF_EXPORT(figure_handle, filename) export the figure whose 4 | % handle is figure_handle to the file given by filename. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, University of Sourthern California, Los 10 | % Angeles, California, USA (2018) 11 | % 12 | % benjamin.girault@usc.edu 13 | % 14 | % This software is a computer program whose purpose is to provide a Matlab 15 | % / Octave toolbox for handling and displaying graph signals. 16 | % 17 | % This software is governed by the CeCILL license under French law and 18 | % abiding by the rules of distribution of free software. You can use, 19 | % modify and/ or redistribute the software under the terms of the CeCILL 20 | % license as circulated by CEA, CNRS and INRIA at the following URL 21 | % "http://www.cecill.info". 22 | % 23 | % As a counterpart to the access to the source code and rights to copy, 24 | % modify and redistribute granted by the license, users are provided only 25 | % with a limited warranty and the software's author, the holder of the 26 | % economic rights, and the successive licensors have only limited 27 | % liability. 28 | % 29 | % In this respect, the user's attention is drawn to the risks associated 30 | % with loading, using, modifying and/or developing or reproducing the 31 | % software by the user in light of its specific status of free software, 32 | % that may mean that it is complicated to manipulate, and that also 33 | % therefore means that it is reserved for developers and experienced 34 | % professionals having in-depth computer knowledge. Users are therefore 35 | % encouraged to load and test the software's suitability as regards their 36 | % requirements in conditions enabling the security of their systems and/or 37 | % data to be ensured and, more generally, to use and operate it in the 38 | % same conditions as regards security. 39 | % 40 | % The fact that you are presently reading this means that you have had 41 | % knowledge of the CeCILL license and that you accept its terms. 42 | 43 | function grasp_clean_pdf_export(figure_handle, filename) 44 | %% Ensure the figure is drawn... 45 | drawnow; 46 | 47 | %% Backup the figure units 48 | prev_units = get(figure_handle, 'Units'); 49 | 50 | %% Prepare the figure paper specs for a PDF output 51 | set(figure_handle, 'Units', 'centimeters'); 52 | pos = get(figure_handle, 'Position'); 53 | set(figure_handle, 'PaperPositionMode', 'Auto', 'PaperUnits', 'centimeters', 'PaperSize', [pos(3), pos(4)]) 54 | 55 | %% Write the PDF 56 | print(filename, '-dpdf'); 57 | 58 | %% Restore the figure units 59 | set(figure_handle, 'Units', prev_units); 60 | end -------------------------------------------------------------------------------- /Util/grasp_is_octave.m: -------------------------------------------------------------------------------- 1 | %Check for Matlab or Octave. 2 | % 3 | % retval = GRASP_IS_OCTAVE() returns true if run from GNU Octave. 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | 8 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 9 | % Inria, FRANCE (2015-11-01) 10 | % 11 | % benjamin.girault@ens-lyon.fr 12 | % 13 | % This software is a computer program whose purpose is to provide a Matlab 14 | % / Octave toolbox for handling and displaying graph signals. 15 | % 16 | % This software is governed by the CeCILL license under French law and 17 | % abiding by the rules of distribution of free software. You can use, 18 | % modify and/ or redistribute the software under the terms of the CeCILL 19 | % license as circulated by CEA, CNRS and INRIA at the following URL 20 | % "http://www.cecill.info". 21 | % 22 | % As a counterpart to the access to the source code and rights to copy, 23 | % modify and redistribute granted by the license, users are provided only 24 | % with a limited warranty and the software's author, the holder of the 25 | % economic rights, and the successive licensors have only limited 26 | % liability. 27 | % 28 | % In this respect, the user's attention is drawn to the risks associated 29 | % with loading, using, modifying and/or developing or reproducing the 30 | % software by the user in light of its specific status of free software, 31 | % that may mean that it is complicated to manipulate, and that also 32 | % therefore means that it is reserved for developers and experienced 33 | % professionals having in-depth computer knowledge. Users are therefore 34 | % encouraged to load and test the software's suitability as regards their 35 | % requirements in conditions enabling the security of their systems and/or 36 | % data to be ensured and, more generally, to use and operate it in the 37 | % same conditions as regards security. 38 | % 39 | % The fact that you are presently reading this means that you have had 40 | % knowledge of the CeCILL license and that you accept its terms. 41 | 42 | function is_octave = grasp_is_octave 43 | persistent is_octave_cache; % speeds up repeated calls 44 | 45 | if isempty(is_octave_cache) 46 | is_octave_cache = numel(ver('Matlab')) == 0; 47 | end 48 | 49 | is_octave = is_octave_cache; 50 | end 51 | -------------------------------------------------------------------------------- /Util/grasp_merge_structs.m: -------------------------------------------------------------------------------- 1 | %Set defaults values to a structure 2 | % 3 | % s_out = GRASP_MERGE_STRUCTS(s_defaults, s_out) set the default values 4 | % of s_out to s_defaults. 5 | % 6 | % ... = GRASP_MERGE_STRUCTS(..., verbose) sets the verbosity (whether or 7 | % not to show a warning when s_out has a field not in s_defaults) 8 | % (default: true). 9 | % 10 | % Authors: 11 | % - Benjamin Girault 12 | % - Benjamin Girault 13 | % - Benjamin Girault 14 | 15 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 16 | % Inria, FRANCE (2015) 17 | % Copyright Benjamin Girault, University of Sourthern California, Los 18 | % Angeles, California, USA (2016-2019) 19 | % Copyright Benjamin Girault, École Nationale de la Statistique et de 20 | % l'Analyse de l'Information, Bruz, FRANCE (2020-2021) 21 | % 22 | % benjamin.girault@ens-lyon.fr 23 | % benjamin.girault@usc.edu 24 | % benjamin.girault@ensai.fr 25 | % 26 | % This software is a computer program whose purpose is to provide a Matlab 27 | % / Octave toolbox for handling and displaying graph signals. 28 | % 29 | % This software is governed by the CeCILL license under French law and 30 | % abiding by the rules of distribution of free software. You can use, 31 | % modify and/ or redistribute the software under the terms of the CeCILL 32 | % license as circulated by CEA, CNRS and INRIA at the following URL 33 | % "http://www.cecill.info". 34 | % 35 | % As a counterpart to the access to the source code and rights to copy, 36 | % modify and redistribute granted by the license, users are provided only 37 | % with a limited warranty and the software's author, the holder of the 38 | % economic rights, and the successive licensors have only limited 39 | % liability. 40 | % 41 | % In this respect, the user's attention is drawn to the risks associated 42 | % with loading, using, modifying and/or developing or reproducing the 43 | % software by the user in light of its specific status of free software, 44 | % that may mean that it is complicated to manipulate, and that also 45 | % therefore means that it is reserved for developers and experienced 46 | % professionals having in-depth computer knowledge. Users are therefore 47 | % encouraged to load and test the software's suitability as regards their 48 | % requirements in conditions enabling the security of their systems and/or 49 | % data to be ensured and, more generally, to use and operate it in the 50 | % same conditions as regards security. 51 | % 52 | % The fact that you are presently reading this means that you have had 53 | % knowledge of the CeCILL license and that you accept its terms. 54 | 55 | function s_out = grasp_merge_structs(s_defaults, s_out, verbose) 56 | if nargin == 2 57 | verbose = true; 58 | end 59 | fields = fieldnames(s_defaults); 60 | for i = 1:numel(fields) 61 | if ~isfield(s_out, fields{i}) 62 | s_out.(fields{i}) = s_defaults.(fields{i}); 63 | end 64 | end 65 | if verbose 66 | cellfun(@(f) warning('GraSP:MergeStruct:MissingDefaultField', ['Field ''' f ''' has no default value, it may be incorrect.']), setxor(fields, fieldnames(s_out))); 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /Util/grasp_parse_varargin.m: -------------------------------------------------------------------------------- 1 | %Parses function parameters given either as key / value parameters or as 2 | %one structure, considering default values. 3 | % 4 | % options = GRASP_PARSE_VARARGIN(default_param) returns default_param. 5 | % 6 | % options = GRASP_PARSE_VARARGIN(default_param, options) if options is a 7 | % cell array, it is interpreted as {key1,value1,key2,value2,...} to 8 | % construct the corresponding structure. This structure is given default 9 | % values according to default_param. 10 | % 11 | % Authors: 12 | % - Benjamin Girault 13 | 14 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 15 | % Inria, FRANCE (2015-11-01) 16 | % 17 | % benjamin.girault@ens-lyon.fr 18 | % 19 | % This software is a computer program whose purpose is to provide a Matlab 20 | % / Octave toolbox for handling and displaying graph signals. 21 | % 22 | % This software is governed by the CeCILL license under French law and 23 | % abiding by the rules of distribution of free software. You can use, 24 | % modify and/ or redistribute the software under the terms of the CeCILL 25 | % license as circulated by CEA, CNRS and INRIA at the following URL 26 | % "http://www.cecill.info". 27 | % 28 | % As a counterpart to the access to the source code and rights to copy, 29 | % modify and redistribute granted by the license, users are provided only 30 | % with a limited warranty and the software's author, the holder of the 31 | % economic rights, and the successive licensors have only limited 32 | % liability. 33 | % 34 | % In this respect, the user's attention is drawn to the risks associated 35 | % with loading, using, modifying and/or developing or reproducing the 36 | % software by the user in light of its specific status of free software, 37 | % that may mean that it is complicated to manipulate, and that also 38 | % therefore means that it is reserved for developers and experienced 39 | % professionals having in-depth computer knowledge. Users are therefore 40 | % encouraged to load and test the software's suitability as regards their 41 | % requirements in conditions enabling the security of their systems and/or 42 | % data to be ensured and, more generally, to use and operate it in the 43 | % same conditions as regards security. 44 | % 45 | % The fact that you are presently reading this means that you have had 46 | % knowledge of the CeCILL license and that you accept its terms. 47 | 48 | function options = grasp_parse_varargin(default_param, options) 49 | if nargin == 1 50 | options = default_param; 51 | else 52 | if iscell(options) 53 | options = cell2struct(options(2:2:end), options(1:2:end), 2); 54 | end 55 | options = grasp_merge_structs(default_param, options); 56 | end 57 | end -------------------------------------------------------------------------------- /Util/grasp_set_blue_red_colormap.m: -------------------------------------------------------------------------------- 1 | %Sets the colormap of an axes to a blue-white-red mapping. 2 | % 3 | % GRASP_SET_BLUE_RED_COLORMAP(hax) sets the axes handle hax to use the 4 | % blue-white-red colormapping for blueredcolormap.mat. 5 | % 6 | % Authors: 7 | % - Benjamin Girault 8 | % - Benjamin Girault 9 | % - Benjamin Girault 10 | 11 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 12 | % Inria, FRANCE (2015-11-01) 13 | % Copyright Benjamin Girault, University of Sourthern California, Los 14 | % Angeles, California, USA (2020) 15 | % Copyright Benjamin Girault, École Nationale de la Statistique et de 16 | % l'Analyse de l'Information, Bruz, FRANCE (2020-2021) 17 | % 18 | % benjamin.girault@ens-lyon.fr 19 | % benjamin.girault@usc.edu 20 | % benjamin.girault@ensai.fr 21 | % 22 | % This software is a computer program whose purpose is to provide a Matlab 23 | % / Octave toolbox for handling and displaying graph signals. 24 | % 25 | % This software is governed by the CeCILL license under French law and 26 | % abiding by the rules of distribution of free software. You can use, 27 | % modify and/ or redistribute the software under the terms of the CeCILL 28 | % license as circulated by CEA, CNRS and INRIA at the following URL 29 | % "http://www.cecill.info". 30 | % 31 | % As a counterpart to the access to the source code and rights to copy, 32 | % modify and redistribute granted by the license, users are provided only 33 | % with a limited warranty and the software's author, the holder of the 34 | % economic rights, and the successive licensors have only limited 35 | % liability. 36 | % 37 | % In this respect, the user's attention is drawn to the risks associated 38 | % with loading, using, modifying and/or developing or reproducing the 39 | % software by the user in light of its specific status of free software, 40 | % that may mean that it is complicated to manipulate, and that also 41 | % therefore means that it is reserved for developers and experienced 42 | % professionals having in-depth computer knowledge. Users are therefore 43 | % encouraged to load and test the software's suitability as regards their 44 | % requirements in conditions enabling the security of their systems and/or 45 | % data to be ensured and, more generally, to use and operate it in the 46 | % same conditions as regards security. 47 | % 48 | % The fact that you are presently reading this means that you have had 49 | % knowledge of the CeCILL license and that you accept its terms. 50 | 51 | function grasp_set_blue_red_colormap(hax) 52 | pwd = [fileparts(mfilename('fullpath')), filesep]; 53 | tmp = load([pwd filesep 'grasp_blueredcolormap.mat']); 54 | bluered = tmp.bluered / 255; 55 | colormap(hax, bluered); 56 | end 57 | -------------------------------------------------------------------------------- /Util/grasp_ternary_op.m: -------------------------------------------------------------------------------- 1 | %Classical ternary operator. 2 | % 3 | %Note: calling GRASP_TERNARY_OP(test, out_true, out_false) directly 4 | %involves Matlab computing out_true and out_false prior to calling 5 | %GRASP_TERNARY_OP. This may not be desirable, and a lazier approach needed 6 | %(for example, if either out_true or out_false is undefined, or return 7 | %errors). In which case, it is more efficient to use EVAL: 8 | %EVAL(GRASP_TERNARY_OP(test, 'out_true_code', 'out_false_code')) 9 | % 10 | % out = GRASP_TERNARY_OP(test, out_true, out_false) ternary operator 11 | % returninig out_true if test is true, and out_false otherwise. 12 | % 13 | % Authors: 14 | % - Benjamin Girault 15 | 16 | % Copyright Benjamin Girault, University of Southern California, USA 17 | % (2017-2019). 18 | % 19 | % benjamin.girault@usc.edu 20 | % 21 | % This software is a computer program whose purpose is to provide a Matlab 22 | % / Octave toolbox for handling and displaying graph signals. 23 | % 24 | % This software is governed by the CeCILL license under French law and 25 | % abiding by the rules of distribution of free software. You can use, 26 | % modify and/ or redistribute the software under the terms of the CeCILL 27 | % license as circulated by CEA, CNRS and INRIA at the following URL 28 | % "http://www.cecill.info". 29 | % 30 | % As a counterpart to the access to the source code and rights to copy, 31 | % modify and redistribute granted by the license, users are provided only 32 | % with a limited warranty and the software's author, the holder of the 33 | % economic rights, and the successive licensors have only limited 34 | % liability. 35 | % 36 | % In this respect, the user's attention is drawn to the risks associated 37 | % with loading, using, modifying and/or developing or reproducing the 38 | % software by the user in light of its specific status of free software, 39 | % that may mean that it is complicated to manipulate, and that also 40 | % therefore means that it is reserved for developers and experienced 41 | % professionals having in-depth computer knowledge. Users are therefore 42 | % encouraged to load and test the software's suitability as regards their 43 | % requirements in conditions enabling the security of their systems and/or 44 | % data to be ensured and, more generally, to use and operate it in the 45 | % same conditions as regards security. 46 | % 47 | % The fact that you are presently reading this means that you have had 48 | % knowledge of the CeCILL license and that you accept its terms. 49 | 50 | function out = grasp_ternary_op(test, out_true, out_false) 51 | if test 52 | out = out_true; 53 | else 54 | out = out_false; 55 | end 56 | end -------------------------------------------------------------------------------- /doc/generate_doc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CUR_DIR=$(pwd) 4 | cd .. 5 | DIRS=$(ls -d --indicator-style=none */ */*/) 6 | cd $CUR_DIR 7 | 8 | mkdir output_mwk output_github_md &> /dev/null 9 | cp tuto.mwk output_mwk/ 10 | pandoc -f mediawiki -t markdown_github tuto.mwk -o output_github_md/tuto.md 11 | 12 | for d in ./ $DIRS 13 | do 14 | git ls-files ../$d --error-unmatch &> /dev/null 15 | if [[ $? -ne 0 ]] 16 | then 17 | continue 18 | fi 19 | TMP_FILES=$(ls ../${d}*m 2> /dev/null) 20 | if [[ $(echo $TMP_FILES | wc -w) -eq 0 ]] 21 | then 22 | continue; 23 | fi 24 | mkdir -p output_mwk/$d output_github_md/$d &> /dev/null 25 | FILE_LIST="" 26 | for f in $TMP_FILES 27 | do 28 | git ls-files $f --error-unmatch &> /dev/null 29 | if [[ $? -eq 0 ]] 30 | then 31 | FILE_LIST="$FILE_LIST $(echo $f | sed -e 's@.*/@@g')" 32 | cd ../$d 33 | OUTPUT_BASENAME=$(echo $f | sed -e 's@^\.\./@@') 34 | awk -f ${CUR_DIR}/matlabhelp2mediawiki.awk $(echo $f | sed -e 's@.*/@@g') > ${CUR_DIR}/output_mwk/${OUTPUT_BASENAME}.mwk 35 | pandoc -f mediawiki -t markdown_github ${CUR_DIR}/output_mwk/${OUTPUT_BASENAME}.mwk -o ${CUR_DIR}/output_github_md/${OUTPUT_BASENAME}.md 36 | cd ${CUR_DIR} 37 | fi 38 | done 39 | echo "== Files ==" > output_mwk/$d/index.mwk 40 | echo "" >> output_mwk/$d/index.mwk 41 | echo "Files" > output_github_md/$d/index.md 42 | echo "-----" >> output_github_md/$d/index.md 43 | echo "" >> output_github_md/$d/index.md 44 | for f in $FILE_LIST 45 | do 46 | CUR_FILENAME=$(echo $f | sed -e 's/\.m$//') 47 | echo "* [[$CUR_FILENAME]]" >> output_mwk/$d/index.mwk 48 | echo "- [$(echo $CUR_FILENAME | sed -e 's@_@\_@')](/$d/$CUR_FILENAME.m.md)" >> output_github_md/$d/index.md 49 | done 50 | # pandoc -f mediawiki -t markdown_github output_mwk/$d/index.mwk -o output_github_md/$d/index.md 51 | done 52 | 53 | 54 | for d in ./ $DIRS 55 | do 56 | DIR_LIST=$(ls -d --indicator-style=none output_mwk/$d/*/ 2> /dev/null) 57 | if [[ $(echo $DIR_LIST | wc -w) -eq 0 ]] 58 | then 59 | continue; 60 | fi 61 | 62 | echo "" >> output_mwk/$d/index.mwk 63 | echo "== Directories ==" >> output_mwk/$d/index.mwk 64 | echo "" >> output_mwk/$d/index.mwk 65 | echo "Directories" > output_github_md/$d/index.md 66 | echo "-----------" >> output_github_md/$d/index.md 67 | echo "" >> output_github_md/$d/index.md 68 | for sd in $DIR_LIST 69 | do 70 | CUR_DIRNAME=$(echo $sd | sed -e 's@/$@@' | sed -e 's@.*/@@g') 71 | echo "* [[$CUR_DIRNAME]]" >> output_mwk/$d/index.mwk 72 | echo "- [$(echo $CUR_DIRNAME | sed -e 's@_@\_@')](/$d/$CUR_DIRNAME/index.md)" >> output_github_md/$d/index.md 73 | done 74 | # pandoc -f mediawiki -t markdown_github output_mwk/$d/index.mwk -o output_github_md/$d/index.md 75 | done 76 | -------------------------------------------------------------------------------- /doc/matlabhelp2mediawiki.awk: -------------------------------------------------------------------------------- 1 | BEGIN { status = 0; new_line_flag = false; synop_list = false; current_line = ""; } 2 | 3 | length($0) == 0 && status < 1000 { 4 | if (synop_list && length(current_line) > 0) { 5 | print current_line 6 | } 7 | status = 1000; 8 | } 9 | 10 | status == 50 { 11 | tmp = substr($0, index($0, $3)) 12 | sub("<.*$", "", tmp) 13 | print "* " tmp 14 | } 15 | 16 | $2 == "Authors:" { 17 | if (synop_list) { 18 | if (length(current_line) > 0) 19 | print current_line 20 | synop_list = false 21 | print "" 22 | } 23 | status = 50 24 | # print "" 25 | print "== Authors ==" 26 | print "" 27 | } 28 | 29 | substr($1, 0, 1) == "%" && (!new_line_flag || index($0, func_name) == 0) && status == 3 { 30 | if (NF == 1) { 31 | new_line_flag = 1 32 | synop_list = 1; 33 | } else { 34 | if (new_line_flag) { 35 | new_line_flag = false 36 | if (synop_list && length(current_line) > 0) 37 | print current_line 38 | current_line = "*" 39 | } 40 | text = substr($0, index($0, $2)) 41 | gsub(func_name, tolower(func_name), text) 42 | if (synop_list) { 43 | current_line = current_line " " text 44 | } else { 45 | print text 46 | } 47 | } 48 | } 49 | 50 | substr($0, 0, 4) == "% " && (status == 2 || status == 1) { 51 | status = 3 52 | new_line_flag = 1 53 | print "" 54 | print "== Synopsis ==" 55 | # print "" 56 | } 57 | 58 | substr($0, 0, 1) == "%" && status == 1 { 59 | status = 2 60 | print "" 61 | print "== Description ==" 62 | print "" 63 | } 64 | 65 | substr($1, 0, 1) == "%" && status == 2 { 66 | if (NR > 1) { 67 | if (substr($0, 2, 1) == " ") { 68 | print "=== " substr($0, index($0, $2)) " ===" 69 | } else { 70 | print substr($0, 2) 71 | } 72 | } 73 | } 74 | 75 | substr($1, 0, 1) == "%" && status == 0 { 76 | if (NR == 1) { 77 | func_name = toupper(substr(FILENAME, 0, length(FILENAME) - 2)); 78 | } 79 | if (length($0) == 1) { 80 | status = 1; 81 | } else { 82 | print substr($0, 2, length($0) - 1) 83 | } 84 | } 85 | 86 | substr($1, 0, 1) == "%" && new_line_flag && index($0, func_name) > 0 && status == 3 { 87 | if (synop_list && length(current_line) > 0) { 88 | print current_line 89 | } 90 | new_line_flag = false 91 | line_start_ind = index($0, $2); 92 | func_ind = index($0, func_name); 93 | eq_ind = index($0, "=") 94 | header = "=== " 95 | if (eq_ind > 0 && eq_ind < func_ind) { 96 | tmp = substr($0, line_start_ind, eq_ind - line_start_ind) 97 | sub(" *$", "", tmp) 98 | header = header "''" tmp "'' = " 99 | } 100 | header = header tolower(func_name) "''" substr($0, index($0, "("), index($0, ")") - index($0, "(") + 1) "''" 101 | print "" 102 | print header " ===" 103 | desc_start = substr($0, index($0, ")") + 2) 104 | if (length(desc_start) > 0) { 105 | print "" 106 | sub(func_name, tolower(func_name), desc_start) 107 | print desc_start 108 | } 109 | synop_list = false; 110 | current_line = ""; 111 | } 112 | 113 | {} 114 | -------------------------------------------------------------------------------- /doc/tuto.mwk: -------------------------------------------------------------------------------- 1 | == Installation == 2 | 3 | Before being able to use the toolbox, several third party tools need to be downloaded and made available to Matlab. To do that, go to the grasp root folder and run the command: 4 | 5 | grasp_install 6 | 7 | Then setup Matlab path to make the GraSP toolbox available to Matlab: 8 | 9 | grasp_start 10 | 11 | You are know ready to use the toolbox. 12 | 13 | == Getting Started == 14 | 15 | First, we need a graph to perform graph signal processing on. You can use the provided functions in [[Graphs]] or any structure you have (we will come back to that later). For example, a random sampling in 2D square, with edges weighted by a Gaussian kernel of the Euclidean distance, is obtained using [[grasp_plane_rnd]]: 16 | 17 | g = grasp_plane_rnd(100); 18 | 19 | The structure g contains now several fields describing this graph. To show this graph, use the [[grasp_show_graph]] function: 20 | 21 | grasp_show_graph(gca, g); 22 | 23 | The first signal we use in this tutorial is a delta signal obtained by [[grasp_delta]]: 24 | 25 | delta_1 = grasp_delta(g, 1); 26 | 27 | We can show it on the previous figure using: 28 | 29 | grasp_show_graph(gca, g, 'node_values', delta_1); 30 | 31 | We observe in the command above a first way of giving optional parameters to functions in the toolbox, using pairs of name and value. The other way of achieving the same goal is through a Matlab structure: 32 | 33 | options = { 'node_values', delta_1 }; 34 | grasp_show_graph(gca, g, options); 35 | 36 | We will use the first form in this tutorial, but sometime the second form is more efficient. 37 | 38 | The next step is to construct the graph Fourier transform. This is done by computing the eigendecomposition of a matrix, and performed by [[grasp_eigendecomposition]]: 39 | 40 | g = grasp_eigendecomposition(g); 41 | 42 | This completes the data structure g with the graph Fourier transform. To perform the GFT on the delta signal we defined, we can use the [[grasp_fourier]] function: 43 | 44 | delta_1_hat = grasp_fourier(g, delta_1); 45 | 46 | Components of delta_1_hat are the Fourier components of the signal delta_1 ordered by increasing frequency. 47 | 48 | Now that the GFT is defined, we can compute a more complex signal using [[grasp_heat_kernel]]: 49 | 50 | heat = grasp_heat_kernel(g); 51 | 52 | This signal is a low pass signal. We can then convolve the two signals using: 53 | 54 | conv_sig = grasp_convolution(g, heat, delta_1); 55 | 56 | You can find more operators in the [[Operators]] folder. 57 | -------------------------------------------------------------------------------- /grasp_bibliography.m: -------------------------------------------------------------------------------- 1 | %Lists bibliography references to cite, including those from optional 2 | %toolboxes. 3 | % 4 | % GRASP_BIBLIOGRAPHY() lists all optional toolboxes that have been 5 | % started, along with URLs to the properly cite the work. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, University of Sourthern California, Los 11 | % Angeles, California, USA (2016-2018) 12 | % 13 | % benjamin.girault@usc.edu 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function grasp_bibliography() 45 | global GRASP_OPT_TOOLS 46 | fprintf('GraSP:\n\thttps://doi.org/10.1109/ICASSP.2017.8005300 -- https://gforge.inria.fr/projects/grasp/\n'); 47 | 48 | opt_tools = grasp_start_opt_3rd_party(0); 49 | for i = 1:numel(GRASP_OPT_TOOLS) 50 | if GRASP_OPT_TOOLS(i) 51 | fprintf('%s:\n', opt_tools(i).name); 52 | if iscell(opt_tools(i).url) 53 | for url = opt_tools(i).url 54 | fprintf('\t%s\n', url{1}); 55 | end 56 | else 57 | fprintf('\t%s\n', opt_tools(i).url); 58 | end 59 | end 60 | end 61 | end -------------------------------------------------------------------------------- /grasp_remove_dependency.m: -------------------------------------------------------------------------------- 1 | %Remove a local dependency previously added by GRASP_ADD_DEPENDENCY. 2 | % 3 | % GRASP_REMOVE_DEPENDENCY(dep) remove dep from the list of local 4 | % dependencies using its name as given by 5 | % GRASP_START_OPT_3RD_PARTY. 6 | % 7 | % Authors: 8 | % - Benjamin Girault 9 | 10 | % Copyright Benjamin Girault, University of Sourthern California, Los 11 | % Angeles, California, USA (2018) 12 | % 13 | % benjamin.girault@usc.edu 14 | % 15 | % This software is a computer program whose purpose is to provide a Matlab 16 | % / Octave toolbox for handling and displaying graph signals. 17 | % 18 | % This software is governed by the CeCILL license under French law and 19 | % abiding by the rules of distribution of free software. You can use, 20 | % modify and/ or redistribute the software under the terms of the CeCILL 21 | % license as circulated by CEA, CNRS and INRIA at the following URL 22 | % "http://www.cecill.info". 23 | % 24 | % As a counterpart to the access to the source code and rights to copy, 25 | % modify and redistribute granted by the license, users are provided only 26 | % with a limited warranty and the software's author, the holder of the 27 | % economic rights, and the successive licensors have only limited 28 | % liability. 29 | % 30 | % In this respect, the user's attention is drawn to the risks associated 31 | % with loading, using, modifying and/or developing or reproducing the 32 | % software by the user in light of its specific status of free software, 33 | % that may mean that it is complicated to manipulate, and that also 34 | % therefore means that it is reserved for developers and experienced 35 | % professionals having in-depth computer knowledge. Users are therefore 36 | % encouraged to load and test the software's suitability as regards their 37 | % requirements in conditions enabling the security of their systems and/or 38 | % data to be ensured and, more generally, to use and operate it in the 39 | % same conditions as regards security. 40 | % 41 | % The fact that you are presently reading this means that you have had 42 | % knowledge of the CeCILL license and that you accept its terms. 43 | 44 | function grasp_remove_dependency(dep) 45 | %% Load the local dependency struct array 46 | pwd = [fileparts(mfilename('fullpath')), filesep]; 47 | thirdparty_dir = [pwd, '3rdParty']; 48 | local_dep_file = [thirdparty_dir '/local_dependencies.mat']; 49 | load(local_dep_file, 'local_dependencies'); 50 | 51 | %% Find the dependency in local_dependencies 52 | dep_index = -1; 53 | for i = 1:numel(local_dependencies) %#ok 54 | if strcmp(local_dependencies{i}.name(1:(end - 1)), dep) 55 | dep_index = i; 56 | break; 57 | end 58 | end 59 | if dep_index == -1 60 | error('Dependency not found!'); 61 | end 62 | 63 | %% Remove it 64 | local_dependencies = local_dependencies([1:(dep_index - 1) (dep_index + 1):end]); %#ok 65 | 66 | %% Save 67 | save(local_dep_file, 'local_dependencies'); 68 | end -------------------------------------------------------------------------------- /grasp_start.m: -------------------------------------------------------------------------------- 1 | %Sets Matlab search path to use this toolbox. 2 | % 3 | % GRASP_START() 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | % - Benjamin Girault 8 | 9 | % Copyright Benjamin Girault, École Normale Supérieure de Lyon, FRANCE / 10 | % Inria, FRANCE (2015) 11 | % Copyright Benjamin Girault, University of Sourthern California, Los 12 | % Angeles, California, USA (2016-2018) 13 | % 14 | % benjamin.girault@ens-lyon.fr 15 | % benjamin.girault@usc.edu 16 | % 17 | % This software is a computer program whose purpose is to provide a Matlab 18 | % / Octave toolbox for handling and displaying graph signals. 19 | % 20 | % This software is governed by the CeCILL license under French law and 21 | % abiding by the rules of distribution of free software. You can use, 22 | % modify and/ or redistribute the software under the terms of the CeCILL 23 | % license as circulated by CEA, CNRS and INRIA at the following URL 24 | % "http://www.cecill.info". 25 | % 26 | % As a counterpart to the access to the source code and rights to copy, 27 | % modify and redistribute granted by the license, users are provided only 28 | % with a limited warranty and the software's author, the holder of the 29 | % economic rights, and the successive licensors have only limited 30 | % liability. 31 | % 32 | % In this respect, the user's attention is drawn to the risks associated 33 | % with loading, using, modifying and/or developing or reproducing the 34 | % software by the user in light of its specific status of free software, 35 | % that may mean that it is complicated to manipulate, and that also 36 | % therefore means that it is reserved for developers and experienced 37 | % professionals having in-depth computer knowledge. Users are therefore 38 | % encouraged to load and test the software's suitability as regards their 39 | % requirements in conditions enabling the security of their systems and/or 40 | % data to be ensured and, more generally, to use and operate it in the 41 | % same conditions as regards security. 42 | % 43 | % The fact that you are presently reading this means that you have had 44 | % knowledge of the CeCILL license and that you accept its terms. 45 | 46 | function grasp_start() 47 | pwd = [fileparts(mfilename('fullpath')), filesep]; 48 | addpath(pwd); 49 | 50 | tmp_dir = '3rdParty'; 51 | addpath([pwd, tmp_dir]); 52 | dep_list = grasp_dependencies_list; 53 | rmpath([pwd, tmp_dir]); 54 | 55 | dirs = {'Duality',... 56 | 'Graphs',... 57 | 'Graphs/Tools',... 58 | 'Operators',... 59 | 'Plotting',... 60 | 'Signals',... 61 | 'Stats',... 62 | 'Util'}; 63 | 64 | for k = 1:numel(dep_list) 65 | if numel(dep_list(k).optional) > 0 && dep_list(k).optional 66 | continue; 67 | end 68 | dir = dep_list(k).name; 69 | if numel(dep_list(k).root_dir) > 0 70 | dir = [dir, dep_list(k).root_dir]; 71 | end 72 | root_path = [pwd, '3rdParty/', dir]; 73 | for p = 1:numel(dep_list(k).path_list) 74 | addpath([root_path, dep_list(k).path_list{p}]); 75 | end 76 | end 77 | 78 | for k = 1:numel(dirs) 79 | addpath([pwd, dirs{k}]); 80 | end 81 | 82 | global GRASP_OPT_TOOLS 83 | GRASP_OPT_TOOLS = []; 84 | end -------------------------------------------------------------------------------- /grasp_stop.m: -------------------------------------------------------------------------------- 1 | %Remove GraSP and its dependencies from Matlab path 2 | % 3 | % GRASP_STOP() 4 | % 5 | % Authors: 6 | % - Benjamin Girault 7 | 8 | % Copyright Benjamin Girault, University of Sourthern California, Los 9 | % Angeles, California, USA (2020) 10 | % 11 | % benjamin.girault@usc.edu 12 | % 13 | % This software is a computer program whose purpose is to provide a Matlab 14 | % / Octave toolbox for handling and displaying graph signals. 15 | % 16 | % This software is governed by the CeCILL license under French law and 17 | % abiding by the rules of distribution of free software. You can use, 18 | % modify and/ or redistribute the software under the terms of the CeCILL 19 | % license as circulated by CEA, CNRS and INRIA at the following URL 20 | % "http://www.cecill.info". 21 | % 22 | % As a counterpart to the access to the source code and rights to copy, 23 | % modify and redistribute granted by the license, users are provided only 24 | % with a limited warranty and the software's author, the holder of the 25 | % economic rights, and the successive licensors have only limited 26 | % liability. 27 | % 28 | % In this respect, the user's attention is drawn to the risks associated 29 | % with loading, using, modifying and/or developing or reproducing the 30 | % software by the user in light of its specific status of free software, 31 | % that may mean that it is complicated to manipulate, and that also 32 | % therefore means that it is reserved for developers and experienced 33 | % professionals having in-depth computer knowledge. Users are therefore 34 | % encouraged to load and test the software's suitability as regards their 35 | % requirements in conditions enabling the security of their systems and/or 36 | % data to be ensured and, more generally, to use and operate it in the 37 | % same conditions as regards security. 38 | % 39 | % The fact that you are presently reading this means that you have had 40 | % knowledge of the CeCILL license and that you accept its terms. 41 | 42 | function grasp_stop() 43 | % Remove GraSP from the path 44 | pwd = fileparts(mfilename('fullpath')); 45 | for p = strsplit(path, ':') 46 | if contains(p, pwd) 47 | rmpath(p{1}); 48 | end 49 | end 50 | 51 | % Reset the list of 3rd party toolboxes started 52 | global GRASP_OPT_TOOLS 53 | GRASP_OPT_TOOLS = []; 54 | end --------------------------------------------------------------------------------