Class PathAll
java.lang.Object
topics.backtracking.paths.PathSimple
topics.backtracking.paths.PathAll
Paths with an Exact Threshold Cost
This class calculates ALL paths (including non-simple paths/cycles) from a source to a target node that match an exact cost threshold.
*Pedagogical Note
Notice that we intentionally ignore the mark[] array in the recursive step.
This allows the algorithm to revisit nodes (looping in cycles) as long as the
accumulated cost is strictly less than the threshold and the length boundary is respected.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class PathSimple
backtracking, getNumberSolutions, getPathString, setTarget, setWeightMatrix, writeWeights
-
Field Details
-
threshold
protected final int threshold
-
-
Constructor Details
-
PathAll
public PathAll(int n, int threshold)
-
-
Method Details
-
setSource
public void setSource(int source) - Overrides:
setSourcein classPathSimple
-
backtrack
protected void backtrack(int current) - Overrides:
backtrackin classPathSimple
-