diff --git a/src/igraph/adjacency.py b/src/igraph/adjacency.py index f941ec822..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, list(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