Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum Weight / Minimum Cost Bipartite Matching Code in Python

I'm searching for Python code for maximum weight / minimum cost matching in a bipartite graph. I've been using the general case max weight matching code in NetworkX, but am finding it too slow for my needs. This is likely due to both the fact that the general algorithm is slower, and the fact that the NetworkX solution is implemented entirely in Python. Ideally, I'd like to find a some Python code for the bipartite matching problem that wraps some C/C++ code, but right now, anything faster than the NetworkX implementation would be helpful.

like image 548
nomad Avatar asked Dec 13 '10 05:12

nomad


People also ask

What is a bipartite matching in G =( L R E?

Definition 1. A graph G = (V,E) is called bipartite if there is a partition of V into two disjoint subsets: V = L ∪ R, such every edge e ∈ E joins some vertex in L to some vertex in R. When the bipartition V = L ∪ R is specified, we sometimes denote this bipartite graph as G = (L, R, E). Theorem 2.

Can we use Ford Fulkerson method to solve maximum bipartite matching?

Maximum bipartite matching solutionSuch a problem can be solved very effectively by the Ford Fulkerson algorithm, which connects and disconnects all possible edges in the graph till the maximum match number is found, such as the highest edge count.

Is bipartite matching P or NP?

Theorem 2 The exact weight perfect matching problem of bipartite graph is NP-complete.


1 Answers

Have you tried scipy implementation of the Hungarian algorithm, also known as the Munkres or Kuhn-Munkres algorithm?

scipy.optimize.linear_sum_assignment

like image 146
Sina Mansour L. Avatar answered Nov 15 '22 16:11

Sina Mansour L.