← Back to Greedy Edge docs

teeline · algorithms/greedy-edge

Greedy Edge Construction

Every pairwise edge is scanned shortest-first and accepted unless it would give a city degree 3+ or close a premature sub-cycle (tracked by a union-find). Watch the components merge until one Hamiltonian cycle remains.

00102030405060708090100110
Union-Find
12 components
{0}
{1}
{2}
{3}
{4}
{5}
{6}
{7}
{8}
{9}
{10}
{11}
accepted edge rejected — degree rejected — cycle closing edge
Press Step or Run to scan the shortest edges first
edges scanned
0/66
accepted
0/12
rejected
0
components
12
partial cost
0
step
0
Edges are parameter-free — no other knobs to tune.
cities: 12candidate edges: 66sort: distance, ascending