Skip to content

Commit

Permalink
Ensure dense adj matrices are contiguous
Browse files Browse the repository at this point in the history
Encountered when calling .shortest_path() on an element of
.connected_subgraphs()
  • Loading branch information
perimosocordiae committed Aug 5, 2016
1 parent dd75c49 commit 3f37b57
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphs/mixins/analysis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import division, absolute_import, print_function
import numpy as np
import scipy.sparse as ss
import scipy.sparse.csgraph as ssc
import warnings
from ..mini_six import range
Expand Down Expand Up @@ -29,6 +30,8 @@ def shortest_path(self, **kwargs):
'''
# ssc.shortest_path requires one of these formats:
adj = self.matrix('dense', 'csr', 'csc')
if not ss.issparse(adj):
adj = np.ascontiguousarray(adj)
return ssc.shortest_path(adj, **kwargs)

def ave_laplacian(self):
Expand Down

0 comments on commit 3f37b57

Please sign in to comment.