Package org.graph4j.hamiltonian
Class BacktrackLongestPathAlgoritm
java.lang.Object
org.graph4j.GraphAlgorithm
org.graph4j.hamiltonian.BacktrackLongestPathAlgoritm
Backtracking algorithm for determining the longest path in a graph (directed
or not).
- Author:
- Cristian Frăsinaru
- See Also:
-
Field Summary
Fields inherited from class org.graph4j.GraphAlgorithm
directed, graph -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the longest path in the graph.getLongestPath(int source) Returns the longest path in the graph, starting in thesourcevertex.getLongestPath(int source, int target) Returns the longest path in the graph, starting in thesourcevertex and ending in thetargetvertex.Methods inherited from class org.graph4j.GraphAlgorithm
getGraph
-
Constructor Details
-
BacktrackLongestPathAlgoritm
-
-
Method Details
-
getLongestPath
Returns the longest path in the graph. If the graph contians more paths of maximum length, it returns the first one found.- Returns:
- the longest path in the graph.
-
getLongestPath
Returns the longest path in the graph, starting in thesourcevertex.- Parameters:
source- the source vertex number.- Returns:
- the longest path in the graph, starting in the
sourcevertex.
-
getLongestPath
Returns the longest path in the graph, starting in thesourcevertex and ending in thetargetvertex.- Parameters:
source- the source vertex number.target- the target vertex number.- Returns:
- the longest path in the graph, starting in the
sourcevertex and ending in thetargetvertex.
-