Exemple #1
0
        public PerimeterFinder(WayFinder wayFinder, Rational[] pathLengths)
        {
            this.wayFinder   = wayFinder;
            this.pathLengths = pathLengths;

            alreadyYeildedPaths = new HashSet <string>();
        }
Exemple #2
0
        public static PointProjectionSolver Solve(PointProjectionSolver solver, Rational otherSide, double metricaBorder = 0, bool usePerimeterFinder = true)
        {
            IEnumerable <List <PPath> > cycles;

            if (usePerimeterFinder)
            {
                var pathLengths = new [] { 1, otherSide, 1, otherSide };
                var wayFinder   = new WayFinder(solver.Graph, pathLengths.Distinct().ToList());
                cycles = new PerimeterFinder(wayFinder, pathLengths).Find();
            }
            else
            {
                var originality = metricaBorder;
                var pathes      = Pathfinder.FindAllPathes(solver.Graph, 1, originality);
                var ps1         = pathes.ToList();

                var ps2 = otherSide == 1
                                ? ps1.ToList()
                                : Pathfinder.FindAllPathes(solver.Graph, otherSide, originality).ToList();

                cycles = Pathfinder.FindAllCycles(ps1, ps2);
            }

            //var cs = cycles.ToList();

            cycleCounter = -1;

            foreach (var c in cycles)
            {
                cycleCounter++;
                var res = TryCycle(solver, c);
                if (res != null)
                {
                    return(res);
                }
            }
            return(null);
        }