From 8d1b8112d841db8c44529105e5ffaebbb52405ec Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 23 Dec 2025 12:14:43 +0100 Subject: [PATCH 1/2] fix: make `get_adjacency_sparse` compatible with scipy 1.13+ --- src/igraph/adjacency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/igraph/adjacency.py b/src/igraph/adjacency.py index f941ec822..e4d2500e5 100644 --- a/src/igraph/adjacency.py +++ b/src/igraph/adjacency.py @@ -113,7 +113,7 @@ def _get_adjacency_sparse(self, attribute=None): weights = self.es[attribute] N = self.vcount() - mtx = sparse.csr_matrix((weights, list(zip(*edges))), shape=(N, N)) + mtx = sparse.csr_matrix((weights, tuple(zip(*edges))), shape=(N, N)) if not self.is_directed(): mtx = mtx + sparse.triu(mtx, 1).T + sparse.tril(mtx, -1).T From 0f5f673b8dae60ef3522a24835277d81b6dbe716 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Tue, 23 Dec 2025 12:28:21 +0100 Subject: [PATCH 2/2] fix for empty graph --- src/igraph/adjacency.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/igraph/adjacency.py b/src/igraph/adjacency.py index e4d2500e5..3d42b0bb2 100644 --- a/src/igraph/adjacency.py +++ b/src/igraph/adjacency.py @@ -113,7 +113,8 @@ def _get_adjacency_sparse(self, attribute=None): weights = self.es[attribute] N = self.vcount() - mtx = sparse.csr_matrix((weights, tuple(zip(*edges))), shape=(N, N)) + r, c = zip(*edges) if edges else ([], []) + mtx = sparse.csr_matrix((weights, (r, c)), shape=(N, N)) if not self.is_directed(): mtx = mtx + sparse.triu(mtx, 1).T + sparse.tril(mtx, -1).T