HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to match two sets of points based on the closeset distance?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thepointsclosesetmatchdistancetwobasedhowsets

Problem

I have a set of points (tiny triangles) $K=\{1,2,\ldots, k\}$ and a set points (tiny circles) $N=\{1,2,\ldots, n\}$ and a matrix of positive real values $\mathbf{D}=\left[d_{ij}\right]$ for all $i\in K$ and for all $j\in N$. The entry of the matrix $d_{ij}$ can be viewed as the Euclidean distance between triangle $i$ and circle $j$.

I would like to assign the triangles to the circles with the constraint that each assigned point is assigned to its closest neighbor. Also, the assignment must be one-to-one. For example, let

$$
\mathbf{D}=\begin{pmatrix}
1 & 1 & 5\\
2 & 3 & 1\\
5 & 8 & 6
\end{pmatrix}.
$$
Now:

  • triangle 1 would like to be assigned to circle 1 or 2 and then 3 (we have a tie);



  • triangle 2 would like to be assigned to circle 3 then 1 and then 2;



  • triangle 3 would like to be assigned to circle 1 then 3 and then 2;



How can I solve this problem?

I thought of creating a list of preferences based on $\mathbf{D}$ like in the example:

  • List of preference for triangle 1: 1, 2, 3



  • List of preference for triangle 2: 3, 1, 2



  • List of preference for triangle 3: 1, 3, 2



But how can I continue on solving this?

Solution

You have an instance of a bipartite matching problem. There are some variations on the problem. I think you're looking for a minimum cost bipartite matching, but maybe you're looking for a stable matching.

Context

StackExchange Computer Science Q#59741, answer score: 4

Revisions (0)

No revisions yet.