An efficient algorithm for the bipartite matching problem