1
$\begingroup$

Let's say there are two lists of objects, list1 and list2, and that there is a function that can generate the "distance" between an object in list1 and an object in list2. What I would like to do is create a list of pairs of objects from each list such that the sum of all the distances of each of the pairs is minimal.

The only method that has occurred to me so far is just a brute force solution of creating a matrix of all the distances between list1 and list2 and then examining the sums of the distances of all possible combinations. Obviously, that approach is rather unappealing. I'm sure that many people have come across a similar problem before but I've been having a hard time phrasing my question in such a way that Google can help me out. Anybody have any ideas?

$\endgroup$
  • $\begingroup$ Maximal/complete matching in a weighed bipartite graph is what I'd be searching for. $\endgroup$ – vonbrand Aug 12 '15 at 21:14
2
$\begingroup$

This seems to be a classical example of bipartite weighted maximum matching, for which there are efficient algorithms (you'll have to convert your minimization objective to a maximization one).

$\endgroup$
  • $\begingroup$ Yes, thank you, that's exactly what this is. Wikipedia has a good run-down of one of the potential algorithm here. $\endgroup$ – sponezzis Aug 12 '15 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.