I have a multidimensionnal array which represent distances between two group of points (colored by blue and red respectively).
import numpy as np
distance=np.array([[30,18,51,55],
[35,15,50,49],
[36,17,40,32],
[40,29,29,17]])
Each column represent the red dot and rows are for blue dots. Values in this matrix represent the distance between red and blue dots. Here is a sketch to understand what it looks like:
Question: How to find the minimum of the sum of distances between mutually disjoint (blue, red) pairs?
Attempt
I am expecting to find 1=1, 2=2, 3=3 and 4=4 in the above image. However, if i use a simple argmin numpy function like:
for liste in distance:
np.argmin(liste)
the result is
1
1
1
3
because the 2 red point is the nearest of 1,2 and 3 blue point.
Is there a way to do something generic in that case to make things better? I mean without using a lot of if statements and a while function.
