示例#1
0
        public static void Main(string[] args)
        {
            bool isFirstRun = true;

            while (true)
            {
                if (isFirstRun)
                {
                    System.Console.WriteLine("UWW CS215 Fano Plane Automorphism Finder" + Environment.NewLine + "Authored by Connor Grady, Grant Jones, and Collin Stolpa");
                }
                else
                {
                    System.Console.WriteLine();
                }
                string input = CollectInput();

                string[] items = new string[7] {
                    "1", "2", "3", "4", "5", "6", "7"
                };

                Permutations          permutations = new Permutations();
                List <List <string> > results      = permutations.GeneratePermutations(items.ToList());
                //WritePermutations(results);

                switch (input)
                {
                case "OutputPerms":
                    WritePermutations(results);
                    break;

                case "OutputAutos":
                    // Now that we have the Permutations, let's check for the automorphisms
                    List <List <string> > automorphisms = results.Where(IsAutomorphism).ToList();

                    // Convert to Cycle Notation
                    List <string> automorphicCycles = automorphisms.Select(perm => permutations.ToCycleNotation(results.FirstOrDefault(), perm)).ToList();

                    // Write cycles to the Console
                    WriteCycles(automorphicCycles, automorphisms.Select(auto => string.Join("", auto)).ToList());
                    break;

                default:
                    System.Console.WriteLine("ERROR: No valid selection detected. Please try again...");
                    break;
                }

                isFirstRun = false;
            }
        }
示例#2
0
        /// <summary>
        /// Specifies whether the provided permutation is an automorphism of the Fano Plane Permutations.
        /// </summary>
        /// <param name="permutation">The permutation derived to check.</param>
        /// <returns>Boolean specifying whether the permutation is an automorphism.</returns>
        private static bool IsAutomorphism(List <string> permutation)
        {
            Permutations permutations = new Permutations();
            // Get the permutation as a set of 7 sets of 3 characters
            List <List <string> > permGroups = permutations.PermTo7SetsOf3(permutation);

            // Get the Fano Plane collection
            List <List <string> > fanoGroups = FanoPlane.GenerateCollection();

            // This will contain the result of all the "true" method comparisons
            // If there are 7 "true" bools at the end, then it is an automorphism
            List <bool> groupBools = new List <bool>(7);

            // For each 3-member group of the permutation
            foreach (List <string> permGroup in permGroups)
            {
                // True if there's at least one 3-member group in the fano plane collection that matches
                // this 3-member group of the permutation
                bool atLeastOneGroupMatches = false;

                // For each 3-member group in the fano collection, for the first group that matches all 3 members (regardless of order),
                // set atLeastOneGroupMatches = true, remove that 3-member group from the fano collection, and break from the loop
                foreach (List <string> fanoGroup in from fanoGroup in fanoGroups let charsMatch = permGroup.All(fanoGroup.Contains) where charsMatch select fanoGroup)
                {
                    atLeastOneGroupMatches = true;
                    fanoGroups.Remove(fanoGroup);
                    break;
                }

                // Add whatever the value of atLeastOneGroupMatches to the bool collection
                groupBools.Add(atLeastOneGroupMatches);
            }

            // Return a boolean whose value is true if the count of all "true" booleans in the bool collection is 7
            return(groupBools.Count(x => x) == 7);
        }