private IEnumerable <Stack <T> > Find(T tStart, int depthMax) { var depthmax = new Depthmax(depthMax); bool fAny = false; var rgtPathStart = new Stack <T>(); rgtPathStart.Push(tStart); var ohlmtVisited = dgentNextByVisited != null ? new Hlm_Chewbacca <T>() : null; foreach (var rgtPath in FindPathRecursive(rgtPathStart, ohlmtVisited, 0, depthmax)) { fAny = true; yield return(rgtPath); } if (!fAny && depthmax.ccut == 0) { throw new Nosol(); } }
private IEnumerable <Stack <T> > FindPathRecursive(Stack <T> rgt, Hlm_Chewbacca <T> ohlmtVisited, int depth, Depthmax depthMax) { var t = rgt.Peek(); if (dgfGoal(t)) { depthMax.D = depth; yield return(new Stack <T>(rgt)); yield break; } if (depth == depthMax.D) { depthMax.ccut++; yield break; } foreach (var tNext in EntNext(rgt, ohlmtVisited)) { if (ohlmtVisited != null) { if (ohlmtVisited.Contains(tNext)) { continue; } ohlmtVisited.Add(tNext); } rgt.Push(tNext); foreach (var tSolution in FindPathRecursive(rgt, ohlmtVisited, depth + 1, depthMax)) { yield return(tSolution); } if (ohlmtVisited != null) { ohlmtVisited.Remove(tNext); } rgt.Pop(); } }