Module org.jgrapht.core
Package org.jgrapht.alg.tour
package org.jgrapht.alg.tour
Graph tours and Hamiltonian path related algorithms.
This package groups algorithms for traversing every vertex of a graph exactly once. Two related but distinct problems live here:
- Hamiltonian cycle / tour — closed traversals that return to the start vertex.
Implementations include
PalmerHamiltonianCycle,HeldKarpTSP, and the various TSP heuristics; they share theHamiltonianCycleAlgorithminterface and theHamiltonianCycleAlgorithmBasehelper class. - Hamiltonian path — open traversals that need not return to the start vertex.
Implementations include
BacktrackingHamiltonianPath,HeldKarpHamiltonianPath, andDagHamiltonianPath; they share theHamiltonianPathAlgorithminterface and theHamiltonianPathAlgorithmBasehelper class.
Deciding whether a Hamiltonian path or cycle exists in a general graph is NP-complete. The
exact algorithms in this package run in exponential time in the worst case; the polynomial
special cases (such as DagHamiltonianPath) and structural prechecks document their
scope individually.
-
ClassesClassDescriptionExact backtracking algorithm for the Hamiltonian path problem on directed and undirected graphs.A $3/2$-approximation algorithm for the metric TSP problem.DagHamiltonianPath<V,
E> Polynomial-time Hamiltonian path algorithm for directed acyclic graphs.The farthest insertion heuristic algorithm for the TSP problem.GreedyHeuristicTSP<V,E> The greedy heuristic algorithm for the TSP problem.Base class for TSP solver algorithms.Base class forHamiltonianPathAlgorithmimplementations.Dynamic-programming algorithm for the Hamiltonian path problem.HeldKarpTSP<V,E> A dynamic programming algorithm for the TSP problem.The nearest insertion heuristic algorithm for the TSP problem.The nearest neighbour heuristic algorithm for the TSP problem.Palmer's algorithm for computing Hamiltonian cycles in graphs that meet Ore's condition.RandomTourTSP<V,E> Generate a random tour.TwoApproxMetricTSP<V,E> A 2-approximation algorithm for the metric TSP problem.TwoOptHeuristicTSP<V,E> The 2-opt heuristic algorithm for the TSP problem.