Skip to content

Instantly share code, notes, and snippets.

@ybenjo
Created May 4, 2020 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ybenjo/c008caabf7b4bf5235b204859c6fcca9 to your computer and use it in GitHub Desktop.
Save ybenjo/c008caabf7b4bf5235b204859c6fcca9 to your computer and use it in GitHub Desktop.
scipy.sparse.csgraph.maximum_bipartite_matching is broken when get complete bipartite graph
from scipy.sparse import lil_matrix, csr_matrix
from scipy.sparse.csgraph import maximum_bipartite_matching
import random
N = 10
M = 10
random.seed(0)
for x in range(5):
mat = lil_matrix((N, M))
for i in range(N):
for j in range(M):
w = random.randint(0, 100)
mat[i, j] = w
mat = csr_matrix(mat)
# solve
print(maximum_bipartite_matching(mat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment