public void ApplyTest()
        {
            var all  = new List <Permutation>();
            int size = 4;
            PermutationGroup group = PermutationGroup.MakeSymN(size);

            group.Apply(new NBacktracker(all));
            Assert.AreEqual(Factorial(size), all.Count);
        }
        public void Apply_FinishEarlyTest()
        {
            List <Permutation> all = new List <Permutation>();
            int max  = 5; // stop after this many seen
            int size = 4;
            PermutationGroup group = PermutationGroup.MakeSymN(size);

            group.Apply(new FinishEarlyBacktracker(all, max));
            Assert.AreEqual(max, all.Count);
        }
        /// <summary>
        /// The automorphism partition is a partition of the elements of the group.
        ///
        /// <returns>a partition of the elements of group</returns>
        /// </summary>
        public Partition GetAutomorphismPartition()
        {
            int n = group.Count;
            DisjointSetForest forest = new DisjointSetForest(n);

            group.Apply(new AutomorphismPartitionBacktracker(n, forest));

            // convert to a partition
            Partition partition = new Partition();

            foreach (var set in forest.GetSets())
            {
                partition.AddCell(set);
            }

            // necessary for comparison by string
            partition.Order();
            return(partition);
        }