Esempio n. 1
0
 public CycleList GetAllCycle(ref CycleList cycles)
 {
     foreach (PathFinder path in childPath)
     {
         path.GetAllCycle(ref cycles);
     }
     foreach (Cycle cycle in this.cycles)
     {
         cycles.Add(cycle);
     }
     return(cycles);
 }
Esempio n. 2
0
        public CycleList GetAllIrregularCycle()
        {
            CycleList outCycleListComplete = new CycleList();

            foreach (Cycle cycle in this)
            {
                if (cycle.IsIrregular())
                {
                    outCycleListComplete.Add(cycle);
                }
            }

            return(outCycleListComplete.EliminateImplicitIrregularities());
        }
Esempio n. 3
0
        public CycleList EliminateImplicitIrregularities()
        {
            CycleList outCycleList = new CycleList();

            for (int cycleSizeToCheck = minMemoryCycle; cycleSizeToCheck < maxMemoryCycle; cycleSizeToCheck++)
            {
                var cycleListToCheck = this.Where(Cycle => Cycle.GetAllNode().Count == cycleSizeToCheck);

                foreach (Cycle cycleToCheck in cycleListToCheck)
                {
                    bool isSubCycleSameAsSmallerCycle = false;
                    for (int startingNode = 0; startingNode < cycleSizeToCheck; startingNode++)
                    {
                        for (int subCircleSize = 4; subCircleSize < cycleSizeToCheck; subCircleSize++)
                        {
                            List <Node> subMemory = new List <Node>();
                            for (int k = 1; k < subCircleSize; k++)
                            {
                                subMemory.Add(cycleToCheck.GetAllNode().ElementAt((startingNode + k) % cycleSizeToCheck));
                            }
                            Cycle subCycle = new Cycle(cycleToCheck.GetAllNode().ElementAt(startingNode), cycleToCheck.GetAllNode().ElementAt(startingNode), subMemory);
                            foreach (Cycle smallerCycle in outCycleList)
                            {
                                if (subCycle.IsSameCycleAs(smallerCycle))
                                {
                                    isSubCycleSameAsSmallerCycle = true;
                                }
                            }
                        }
                    }
                    if (!isSubCycleSameAsSmallerCycle)
                    {
                        outCycleList.Add(cycleToCheck);
                    }
                }
            }

            return(outCycleList);
        }
Esempio n. 4
0
        public PathFinder(Node start, Node end, List <Node> memory = null, bool isOrigin = false, Node current = null)
        {
            this.start    = start;
            cycles        = new CycleList();
            childPath     = new List <PathFinder>();
            completedPath = new List <Path>();
            this.current  = (current == null)?start:current;
            this.end      = end;
            if (memory == null)
            {
                this.memory = new List <Node>();
            }
            else
            {
                this.memory = memory;
            }


            if (!isOrigin)
            {
                this.memory.Add(current);
            }
            string outString = "Start of " + current + ". Memory is composed of ";

            foreach (Node node in this.memory)
            {
                outString += node.Name + ", ";
            }
            Console.Out.WriteLine(outString);

            //Console.Out.WriteLine(ToString());

            foreach (Node neighbor in this.current.Neighbors)
            {
                if (!this.memory.Contains(neighbor))
                {
                    if (neighbor == start)
                    {
                        if (!(this.memory.Count <= 1))
                        {
                            cycles.Add(new Cycle(start, end, this.memory));
                        }
                    }
                    else if (neighbor == end)
                    {
                        completedPath.Add(new Path(start, end, this.memory));
                        childPath.Add(new PathFinder(start, end, this.memory, false, neighbor));
                    }
                    else
                    {
                        childPath.Add(new PathFinder(start, end, this.memory, false, neighbor));
                    }
                }
            }
            this.memory.Remove(current);
            outString = "End of " + current + ". Memory is composed of ";
            foreach (Node node in this.memory)
            {
                outString += node.Name + ", ";
            }
            Console.Out.WriteLine(outString);
        }