Traveling Salesman Problem - Sorted Edges Algorithm


A graph is a finite set of dots and connecting links. The dots are called vertices (a single dot is a vertex), and the links are called edges. Each edge must connect two different vertices. A path is a connected sequence of edges showing a route on the graph that starts at a vertex and ends at a vertex. A circuit is a path that starts and ends at the same vertex. Circuits that visit each vertex once and only once are called Hamiltonian circuits.

Imagine now a graph where each edge is given a weight. This weight could be the distance or cost to get from one vertex to another. The sum of these weights for a given path is then the cost of that path. The problem of finding a Hamiltonian circuit with a minimum cost is often called the traveling salesman problem (TSP).

One strategy for solving the traveling salesman problem is the sorted edge algorithm. It proceeds by listing the weights in increasing order, and then choosing an edge having the smallest weight that (1) never completes a circuit that does not include all the vertices, and that (2) never has more than two edges meeting at a vertex.

In the applet below your first task is to sort the edges in increasng order. Click on an edge to select it. Once the edges have been sorted, you may start adding to your circuit. Again just click the edge you want to select. The Reset button will return the graph to its original state. The New Graph button will load a new graph.