#2optSwap

Alexandre B A Villaresvillares@pynews.com.br
2025-02-15

Comparing a naive "nearest neighbor" #TravellingSalesmanProblem solver with a #2optSwap one, adding a #DelaunayTriangulation mesh, it shows how often the better solution falls into the triangulation!

The #py5 sketch is interactive, you can generate other random nodes and move them around dragging with the mouse.

Code at: github.com/villares/sketch-a-d
More sketch-a-day: abav.lugaralgum.com/sketch-a-d
If you like this, support my work: paypal.com/donate/?hosted_butt
#scipy #Processing #Python #TSP #CreativeCoding

diagram of black circles connected on a Dalaunay triagulation with white lines, a nearest neightbor TSP tour in purple and "two opt swap" (better) tour in blue.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst