Class PathAll

java.lang.Object
topics.backtracking.paths.PathSimple
topics.backtracking.paths.PathAll

public class PathAll extends PathSimple

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 Details

    • threshold

      protected final int threshold
  • Constructor Details

    • PathAll

      public PathAll(int n, int threshold)
  • Method Details