← Back to 2-opt docs

teeline · algorithms/2opt

2-opt Local Search

2-opt iteratively improves a tour by removing two edges and reconnecting the resulting segments in the only other valid way — reversing the segment between the two removed edges. Each pass scans all edge pairs and applies the best-improving swap; the algorithm stops when no improving swap exists (local optimum).

4093618257
tour edge candidate (remove) candidate (add) removed new edge
Click Step to scan for improving swaps
pass
0
swaps
0
best cost
2018
step
0
cities: 10best-improvement 2-opt