1
$\begingroup$

I have a list of people's locations on a world map and want to pair nearby people up such that the number of pairs is maximized.

For example, subject to the constraint that paired people are within d=10 miles of each other, I might find 742 pairs from a list of n=3000 people's locations.

Possible considerations:

  • alright to assume the world is a 2D Euclidean plane

  • alright to assume n < 100000

  • the distance constraint can be relaxed, for example to a cost function with a high value after 10

  • as in real life, people cluster in cities, so there might be many people "0 miles apart" in New York City while people in Wyoming are few and far apart.

  • any leads on the same problem above but for triplets would be great. That is, the same problem, but instead of two you take three people and group them together, preferably with the constraint still being that the three are contained in a d-diameter disc, though other similar constraints are fine.

A simple approach

  • calculate all-pairs distances.

    • in the process create an array of pairs sorted from closest to farthest

    • in the process, for each person, store a list of people within d miles

  • greedily pair together the closest unpaired people

  • repeat the following until no progress has been made for a certain number of loops

    • find an unpaired person p_1 with closest person p_2 <= d miles of them. person p_2 is currently paired to person p_3.

    • unpair p_2 and p_3 and pair p_1 and p_2. If any exist, pair p_3 to a closest person p_4 that is unpaired and within d miles.

I'm sure there are many interesting approaches to this problem, and would any love input on what research/search terms I could look into to learn more about it, any ideas for algorithms to solve this, and possibly bounds on how well the above algorithm would work on the problem.

Thank you

$\endgroup$

1 Answer 1

2
$\begingroup$

You can formulate this as a maximum matching problem in an undirected graph, and then apply standard algorithms for this problem, such as Edmonds' algorithm. These algorithms are reasonably efficient and should be fast for your parameters, and they are guaranteed to find the optimal collection of pairings.

In particular, the graph is as follows. You have a vertex for each person. Draw an edge between two people if they are within 10 miles of each other. Now, you want a maximum matching in this undirected graph: i.e., a collection of edges (pairs of people) such that no two edges have a vertex in common (each person is paired up with at most one other person), and that is as large as possible.

There's lots written on the maximum matching problem; a search should turn up plenty of additional information.

$\endgroup$
2
  • $\begingroup$ Generally speaking, if you want to group $k$ people together you want to find the largest (edge-wise) subgraph $G'$ so that $\Delta(G') < k$. As you described, finding a solution for $k = 2$ (pairs of people) is equivalent to finding a maximum matching since it is the largest subgraph of maximum degree $1$. How would you proceed for different values of $k$? $\endgroup$
    – Roukah
    Commented Jun 7, 2017 at 8:26
  • $\begingroup$ @Roukah, I don't know. We could call it the disjoint $k$-cliques problem, I suppose. I don't know if it has been studied in general graphs, or in this particular kind of graph. Sounds worth asking separately as a new question! $\endgroup$
    – D.W.
    Commented Jun 7, 2017 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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