Bug in scipy.sparse.csgraph.min_weight_full_bipartite_matching
See original GitHub issuemin_weight_full_bipartite_matching gets stuck when running, python is not responding to SIGINT, needed to use cltr+\ to send SIGTERM.
To reproduce:
import pickle
from scipy.sparse.csgraph import min_weight_full_bipartite_matching
t = ... # see comment bellow
min_weight_full_bipartite_matching(t)
The matrix is a coo matrix, which is representing the dense matrix below, all 0s are implicit (no 0 values in coo matrix):
[[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.001 ]
[0. 0.11687445 0. 0. 0.01319788 0.07509257 0. 0. 0. 0.74228317 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0.81087935 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0.8408466 0. 0. 0. 0. 0.01194389 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0.82994211 0. 0. 0. 0.11468516 0. 0. 0. 0.11173505 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.18796507 0. 0.04002318 0. 0. 0. 0. 0. 0.75883335 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0.71545464 0. 0. 0. 0. 0. 0.02748488 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.78470564 0. 0. 0. 0. 0. 0. 0. 0.14829198 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0.10870609 0. 0. 0. 0.8918677 0. 0. 0. 0.06306644 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.63844085 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0.7442354 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.09850549 0. 0. 0.18638258 0.2769244 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.73182464 0. 0. 0.46443561 0.38589284 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.29510278 0. 0. 0. 0. 0. 0. 0. 0.09666032 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ]]
Issue Analytics
- State:
- Created a year ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
scipy.sparse.csgraph.min_weight_full_bipartite_matching
Returns the minimum weight full matching of a bipartite graph. New in version 1.6.0. Parameters. biadjacency_matrixsparse matrix. Biadjacency matrix of the ...
Read more >BUG: Incorrect residual graph in scipy.sparse.csgraph ...
Describe your issue. Consider the reproducing example below. This seems to be the incorrect residual graph from the flow. 1-2 has a 5...
Read more >what is wrong with importing modules in scipy , is it a bug?
This is an artifact of Python's importing, not of SciPy. Do from scipy import sparse [as sp]. or import scipy.sparse [as sp].
Read more >scipy.sparse.csgraph.construct_dist_matrix
Parameters: grapharray_like or sparse. The N x N matrix representation of a directed or undirected graph. If dense, then non-edges are indicated by...
Read more >Compressed sparse graph routines ... - CuPy
Compressed sparse graph routines ( cupyx.scipy.sparse.csgraph )#. Note. The csgraph module uses pylibcugraph as a backend. You need to install pylibcugraph ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @Code-Gratefully , you are right: since the matrix was square I misinterpreted it as an adjacency matrix rather than a biadjacency matrix (which, as you point out, the
csgraph.min_weight_full_bipartite_matching
docs explicitly warn against) - my mistake!If we instead interpret the input matrix correctly as a biadjacency matrix, then we hit a different exception in NetworkX:
Note that the NetworkX version just calls
scipy.optimize.linear_sum_assignment
on the dense biadjacency_matrix (withinf
representing non-edges rather than 0), which is where the exception originates. Full traceback included belowTraceback
The next step would be to chase down why specifically the input is infeasible, then see if that’s something that
csgraph.min_weight_full_bipartite_matching
can check for to raise an exception rather than hang.Sure, how about this plain code: