Class HamiltonianPathAlgoAbstract
- All Implemented Interfaces:
HamiltonianPathAlgo
- Direct Known Subclasses:
HamiltonianPathAlgoAbstractBasedCycle
The class implements the interface by solving the problem on the index graph and then maps the results back to the original graph. The implementation for index graphs is abstract and left to the subclasses.
- Author:
- Barak Ugav
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionhamiltonianCyclesIter
(Graph<V, E> g) Iterate over all Hamiltonian cycles in the given graph.hamiltonianPathsIter
(Graph<V, E> g) Iterate over all Hamiltonian paths in the given graph.hamiltonianPathsIter
(Graph<V, E> g, V source, V target) Iterate over all Hamiltonian paths in the given graph that start and end at two given vertices.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jgalgo.alg.hamilton.HamiltonianPathAlgo
hamiltonianCycle, hamiltonianPath, hamiltonianPath
-
Constructor Details
-
HamiltonianPathAlgoAbstract
public HamiltonianPathAlgoAbstract()Default constructor.
-
-
Method Details
-
hamiltonianPathsIter
Description copied from interface:HamiltonianPathAlgo
Iterate over all Hamiltonian paths in the given graph.An Hamiltonian path is a path that visits each vertex of the graph exactly once. This method returns an iterator that iterate over all Hamiltonian paths in the graph. Each returned path will start and end at two arbitrary vertices.
If the graph has no vertices, this methods returns an empty iterator. If the graph has only one vertex, this method returns an iterator that iterate over a single empty path (which is actually a cycle).
If
g
isIntGraph
, the returned iterator will iterate overIPath
objects.- Specified by:
hamiltonianPathsIter
in interfaceHamiltonianPathAlgo
- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- the graph- Returns:
- an iterator that iterate over all Hamiltonian paths in the graph
-
hamiltonianPathsIter
Description copied from interface:HamiltonianPathAlgo
Iterate over all Hamiltonian paths in the given graph that start and end at two given vertices.An Hamiltonian path is a path that visits each vertex of the graph exactly once. This method returns an iterator that iterate over all Hamiltonian paths in the graph that start at
source
and end attarget
.If the source and target are the same vertex, the returned iterator will iterate over all Hamiltonian cycles in the graph.
If
g
isIntGraph
, the returned iterator will iterate overIPath
objects.- Specified by:
hamiltonianPathsIter
in interfaceHamiltonianPathAlgo
- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- the graphsource
- the source vertextarget
- the target vertex- Returns:
- an iterator that iterate over all Hamiltonian paths in the graph that start at
source
and end attarget
-
hamiltonianCyclesIter
Description copied from interface:HamiltonianPathAlgo
Iterate over all Hamiltonian cycles in the given graph.An Hamiltonian cycle is a cycle that visits each vertex of the graph exactly once. This method returns an iterator that iterate over all Hamiltonian cycles in the graph.
If the graph has no vertices, this methods returns an empty iterator. If the graph has only one vertex, this method returns an iterator that iterate over a single empty cycle.
If
g
isIntGraph
, the returned iterator will iterate overIPath
objects.- Specified by:
hamiltonianCyclesIter
in interfaceHamiltonianPathAlgo
- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- the graph- Returns:
- an iterator that iterate over all Hamiltonian cycles in the graph
-