org.jgrapht.alg

## Class HamiltonianCycle

• ```public class HamiltonianCycle
extends Object```
This class will deal with finding the optimal or approximately optimal minimum tour (hamiltonian cycle) or commonly known as the Traveling Salesman Problem.
Author:
Andrew Newell
• ### Constructor Summary

Constructors
Constructor and Description
`HamiltonianCycle()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static <V,E> List<V>` `getApproximateOptimalForCompleteGraph(SimpleWeightedGraph<V,E> g)`
This method will return an approximate minimal traveling salesman tour (hamiltonian cycle).
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### HamiltonianCycle

`public HamiltonianCycle()`
• ### Method Detail

• #### getApproximateOptimalForCompleteGraph

`public static <V,E> List<V> getApproximateOptimalForCompleteGraph(SimpleWeightedGraph<V,E> g)`
This method will return an approximate minimal traveling salesman tour (hamiltonian cycle). This algorithm requires that the graph be complete and the triangle inequality exists (if x,y,z are vertices then d(x,y)+d(y,z) < d(x,z) for all x,y,z) then this algorithm will guarantee a hamiltonian cycle such that the total weight of the cycle is less than or equal to double the total weight of the optimal hamiltonian cycle. The optimal solution is NP-complete, so this is a decent approximation that runs in polynomial time.
Type Parameters:
`V` - the graph vertex type
`E` - the graph edge type
Parameters:
`g` - is the graph to find the optimal tour for.
Returns:
The optimal tour as a list of vertices.