From 09b382098cb9c9ced6312e4a86339754f44f6be8 Mon Sep 17 00:00:00 2001 From: alberto Date: Thu, 9 Apr 2026 18:44:53 +0200 Subject: [PATCH] Try graph plotting and add breakdown. --- pyproject.toml | 1 + report/main.tex | 30 ++++++++---------------------- src/afgl/lanczos.py | 2 ++ src/afgl/main.py | 24 ++++++++++++++++++++++-- uv.lock | 14 ++++++++++++++ 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a259237..be1a9ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ dependencies = [ "matplotlib>=3.10.8", "numpy>=2.0.0", "pygsp>=0.6.1", + "scienceplots>=2.2.1", "scipy>=1.10.0", ] requires-python = ">=3.10" diff --git a/report/main.tex b/report/main.tex index bf57a3e..4761044 100644 --- a/report/main.tex +++ b/report/main.tex @@ -3,11 +3,12 @@ % Load bibliography \addbibresource{references.bib} -\usepackage{lipsum} % Just for the demo text % --- Document Metadata --- -\title{\normalfont\scshape\Large The Geometry of Complex Systems} -\author{\normalfont\itshape A. N. Other} +\title{% + Accelerated filtering on graphs using Lanczos method + \\ \large Relazione del progetto di Calcolo Scientifico} +\author{Alberto Defendi} \date{\small\today} \begin{document} @@ -15,30 +16,15 @@ \maketitle \begin{abstract} - \noindent \small \textbf{\textit{Abstract.}} \lipsum[1][1-4] + \noindent \small \textbf{\textit{Abstract.}} \end{abstract} \section{Introduction} -This document uses a custom class file (\texttt{mathreport.cls}). This keeps the main file clean. The typography is set to Bringhurst's standards: wide margins, Palatino font, and old-style figures (e.g., 12345). -\section{Mathematical Theory} -We define our primary operator in the Hilbert space $\mathcal{H}$. +Introduciamo alcuni concetti di teoria dei grafi e alcuni risultati del corso che verranno usati nel corso della sperimentazione. +Scopo del progetto รจ verificare numericamente i risultati -\begin{definition}[Compact Operator] - An operator $T: X \to Y$ is compact if $\overline{T(B_X)}$ is compact in $Y$. -\end{definition} - -\begin{theorem}[Spectral Theorem] - There exists an orthonormal basis of eigenvectors. -\end{theorem} - -Consider the harmonic series shown in \cref{eq:harmonic}. The styling is handled entirely by the external class file. -\begin{equation} \label{eq:harmonic} - H_n = \sum_{k=1}^n \frac{1}{k} \approx \ln n + \gamma -\end{equation} - -\section{Results and Discussion} -\lipsum[2-4] +Nell'analisi consideriamo i grafi di Erdo''s-Reiny (Figura) \printbibliography diff --git a/src/afgl/lanczos.py b/src/afgl/lanczos.py index 5cd2305..3797a16 100644 --- a/src/afgl/lanczos.py +++ b/src/afgl/lanczos.py @@ -35,6 +35,8 @@ def lanczos(L, s, M): if j < M - 1: beta[j] = LA.norm(v_tilde) + if beta[j] == 0: + break V[:, j + 1] = v_tilde / beta[j] return [V, alp, beta] diff --git a/src/afgl/main.py b/src/afgl/main.py index 9b17697..a54cbc6 100644 --- a/src/afgl/main.py +++ b/src/afgl/main.py @@ -1,10 +1,30 @@ # src/afgl/main.py import sys +import matplotlib.pyplot as plt +import numpy as np +from pygsp import graphs, plotting + + +def test_plot(): + plotting.BACKEND = "matplotlib" + plt.style.use(["science"]) + fig, ax = plt.subplots(figsize=(3.3, 2.5)) + # G = graphs.ErdosRenyi() + G = graphs.Sensor() + + G.set_coordinates() + + signal = np.sin(G.coords[:, 0] * 10) + + G.plot(signal, ax=ax, vertex_size=15, edge_width=0.5, edge_color="gray") + ax.set_title(r"Sensor Network $\mathcal{G} = (\mathcal{V}, \mathcal{E})$") + ax.set_axis_off() + plt.savefig("./out/test.pdf", bbox_inches="tight") + def run(): - """Main execution function.""" - print("Starting the Accelerated Filtering Graphs Lanczos (AFGL) process...") + test_plot() if __name__ == "__main__": diff --git a/uv.lock b/uv.lock index d9c0ffb..624652c 100644 --- a/uv.lock +++ b/uv.lock @@ -15,6 +15,7 @@ dependencies = [ { name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, { name = "numpy", version = "2.4.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, { name = "pygsp" }, + { name = "scienceplots" }, { name = "scipy", version = "1.15.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, { name = "scipy", version = "1.17.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, ] @@ -24,6 +25,7 @@ requires-dist = [ { name = "matplotlib", specifier = ">=3.10.8" }, { name = "numpy", specifier = ">=2.0.0" }, { name = "pygsp", specifier = ">=0.6.1" }, + { name = "scienceplots", specifier = ">=2.2.1" }, { name = "scipy", specifier = ">=1.10.0" }, ] @@ -737,6 +739,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, ] +[[package]] +name = "scienceplots" +version = "2.2.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "matplotlib" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ae/a5/5f858668ca1a513033a7f0d55cd12b0940a12e822f9f61f317ce344e07c6/scienceplots-2.2.1.tar.gz", hash = "sha256:51ad98c420e499d3284d07b6447a4b3aedd8ec122aca39ba91c58205226c408a", size = 17966, upload-time = "2026-02-25T01:26:54.603Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/22/14e7b20f7d11f3e9ea9b5ae6acf9ea695c423eee785906cd5c5914a841dc/scienceplots-2.2.1-py3-none-any.whl", hash = "sha256:a1a9f670cbf5b59d92cdd3250be85b079ee4cf08bcaf2ace5ef57995be0b6c42", size = 30237, upload-time = "2026-02-25T01:26:53.298Z" }, +] + [[package]] name = "scipy" version = "1.15.3"