public TraversalBacktracker(
     String original, PermutationGroup symN, IntGraph g, PermutationGroup aut) {
   this.graph = g;
   this.aut = aut;
   this.results = new ArrayList<Permutation>();
   this.maxSize = symN.order() / aut.order();
   this.size = g.getVertexCount();
   this.original = original;
 }
  public void applyTo(Permutation p) {
    String permuted = graph.getSortedPermutedEdgeString(p.getValues());

    if (original.compareTo(permuted) > 0) {
      finished = true;
      return;
    }

    for (Permutation f : results) {
      Permutation h = f.invert().multiply(p);
      if (aut.test(h) == size) {
        return;
      }
    }
    results.add(p);
    if (results.size() >= this.maxSize) {
      this.finished = true;
    }
  }