Skip to main content

scirs2_graph/signal_processing/
mod.rs

1//! Graph Signal Processing (GSP) module.
2//!
3//! This module provides tools for analysing and processing signals defined on
4//! the vertices of a graph, using the spectral theory of graph Laplacians.
5//!
6//! ## Submodules
7//!
8//! | Module | Contents |
9//! |--------|----------|
10//! | [`gsp`] | Graph Fourier Transform, spectral filters (LP/HP/BP), diffusion wavelets, Tikhonov smoother |
11//! | [`sampling`] | Optimal sampling set selection, bandlimited reconstruction, Gershgorin bounds, uncertainty principle |
12//!
13//! ## Quick start
14//!
15//! ```rust,no_run
16//! use scirs2_core::ndarray::{Array1, Array2};
17//! use scirs2_graph::signal_processing::gsp::{GraphFourierTransform, IdealLowPass, GraphFilter};
18//! use scirs2_graph::signal_processing::sampling::{GraphSampling, BandlimitedReconstruction};
19//!
20//! // Build a small path graph
21//! let mut adj = Array2::<f64>::zeros((6, 6));
22//! for i in 0..5_usize {
23//!     adj[[i, i+1]] = 1.0;
24//!     adj[[i+1, i]] = 1.0;
25//! }
26//!
27//! // Graph Fourier Transform + low-pass filtering
28//! let gft = GraphFourierTransform::from_adjacency(&adj).unwrap();
29//! let signal = Array1::from_vec(vec![1.0, 0.5, 0.0, -0.5, -1.0, -0.5]);
30//! let smoothed = IdealLowPass::new(2).apply(&gft, &signal).unwrap();
31//!
32//! // Optimal sampling and reconstruction
33//! let sampler = GraphSampling::new(2);
34//! let set = sampler.greedy_sampling_set(&gft).unwrap();
35//! let samples = Array1::from_iter(set.iter().map(|&i| signal[i]));
36//! let rec = BandlimitedReconstruction::new(2)
37//!     .reconstruct(&gft, &set, &samples)
38//!     .unwrap();
39//! ```
40
41pub mod gsp;
42pub mod sampling;
43
44// Re-export the most commonly used types
45pub use gsp::{
46    GraphBandpass, GraphFilter, GraphFourierTransform, GraphSignalSmoother, GraphWavelet,
47    IdealHighPass, IdealLowPass,
48};
49pub use sampling::{
50    BandlimitedReconstruction, GershgorinBound, GraphSampling, GraphUncertaintyPrinciple,
51};