Skip to content

Commit 588a194

Browse files
authored
Merge pull request #872 from flying-sheep/fix-get-adjacency-sparse
2 parents 7ad93fb + 0f5f673 commit 588a194

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/igraph/adjacency.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def _get_adjacency_sparse(self, attribute=None):
113113
weights = self.es[attribute]
114114

115115
N = self.vcount()
116-
mtx = sparse.csr_matrix((weights, list(zip(*edges))), shape=(N, N))
116+
r, c = zip(*edges) if edges else ([], [])
117+
mtx = sparse.csr_matrix((weights, (r, c)), shape=(N, N))
117118

118119
if not self.is_directed():
119120
mtx = mtx + sparse.triu(mtx, 1).T + sparse.tril(mtx, -1).T

0 commit comments

Comments
 (0)