-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MemoryError in scipy.sparse.csgraph.shortest_path #2526
Comments
@jakevdp I guess you're interested in this one |
The value returned by the shortest_path functions is an From your question, though, it sounds like you don't care about the full |
Hi Jake, I want to compute the My assumption was that passing a sparse matrix to the function I would have got back a sparse matrix, hence my puzzlement at seeing the creation of a dense matrix. I can agree that not being the general case this probably cannot be considered a defect, but rather a feature request. Or maybe the docstring could be updated to reflect this detail of the semantic of the function? Cheers |
I'm pretty sure that in the world of scipy sparse matrices, entries that are missing from the matrix are interpreted as zero, so a matrix consisting of mostly inf would not be treated as sparse. On the other hand, there seems to be work afoot with sparse bool matrices that is considering allowing both 'mostly true' and 'mostly false' matrices to be handled sparsely, so maybe there could be a 'mostly inf' matrix following this idea. Or maybe an alternate function could be defined that returns the |
Fair point. I didn't think of the problem with the Infs: in my application weights are > 0 so I was interpreting any off-diagonal 0 as an infinite distance. The idea of returning the reciprocal of the distances seems really neat. Btw, could you please point to the sparse bool matrices code? Thanks! |
It is under construction by @cowlicks for google summer of code. |
Thanks! |
The doc string of I agree that allowing the function to construct a sparse matrix might be useful in some special cases, but you'd probably want a separate function for that. If you'd like to implement it, I wouldn't mind 😄 |
For what it's worth, networkx will do all_pairs_dijkstra_path_length in a way that gives a sparse output. I often end up using networkx and dictionaries instead of scipy.sparse... |
Thanks! |
Hi,
I want to compute the shortest path distances in a sparse directed graph with 2M nodes but scipy.csgraph.shortest_path immediately throws a MemoryError -- regardless of the chosen method. This is what I do:
And this is what I get:
It seems that there are two distinct issues:
The text was updated successfully, but these errors were encountered: