← Back to 3-opt docs

teeline · algorithms/3opt

3-opt Local Search

3-opt removes three edges and reconnects the three resulting segments in one of seven ways (2-opt only has one). Cases 1–3 reverse segments; cases 4–7 swap segments — the moves 2-opt cannot express. Each pass scans all triples and applies the single best-improving reconnection, repeating until no triple yields an improvement.

0341258967
ABCDEF
1
ABCDEF
2
ABCDEF
3
ABCDEF
4
ABCDEF
5
ABCDEF
6
ABCDEF
7
tour edge removed new edge chosen pattern
Click Step to scan triples for the best 3-opt reconnection
pass
0
swaps
0
best cost
1367
distance
1367
last Δ
step
0
cities: 10O(n³) triple scan · 7 reconnections · best-improvement