Yes, the Hungarian algorithm for weighted bipartisan correspondence.
For each edge between an element from A and an element from B, let the weight of this edge be the distance between them. Then run the Hungarian algorithm to minimize the total weight.
The total execution time is O (| A | ^ 3).
source share