How to connect points most efficiently?

Hello,
I want to connect Points A and B in with the shortest distances, but they also should cross each other the least amount possible, probably something like the picture.
Sorting the points distances purely by length would make some points have multiple connections and some points have no connections. It would be better if the connection is made in a way that produces the shortest total length, while also crossing each other.

In the exmplary picture, point 1 should connect to point B, although point A has a shorter distance. How should I think about this problem?



sonnenvektor matrix hilfe.gh (10.9 KB)

You didn’t internalize your geometry.

Yes, sorry! I am attaching one with internalized geometry.
sonnenvektor matrix hilfe internalized.gh (12.8 KB)

There are some weird aspects to this code, perhaps including the basic premise…

Still, I used an Anemone 0.4 loop (white group) to avoid using any point twice.


sonnenvektor matrix hilfe_2024Jun4a.gh (24.3 KB)

Added slider to Shift List:


sonnenvektor matrix hilfe_2024Jun4b.gh (25.5 KB)

Does this alternative look correct to you visually?
sonnenvektor matrix hilfe internalized.gh (17.4 KB)


image

Haha, yes? What is wrong with the basic premise?

Thank you for your code!