static void Main(string[] args)
        {
            //Importa klasana
            QuickFind          quickFind   = new QuickFind(10);
            QuickUnion         quickUnion  = new QuickUnion(10);
            WeightedQuickUnion wQuickUnion = new WeightedQuickUnion(10);
            WeightedQuickUnionPathCompression wQuickUnionPath = new WeightedQuickUnionPathCompression(10);



            //Kalla í test functionin
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Quick Find Test: ");
            quickFind.test();
            Console.WriteLine("\nQuick Union Test: ");
            quickUnion.test();
            Console.WriteLine("\nWeighted Quick Union Test: ");
            wQuickUnion.test();
            Console.WriteLine("\nWeighted Quick Union + Path Compression Test: ");
            wQuickUnionPath.test();

            Console.WriteLine("\n\n\nLiður D");
            Console.WriteLine("\nQuick Find: ");
            quickFind.LidurD();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("\nQuick Union:");
            quickUnion.LidurD();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("\nWeighted Quick Union: ");
            wQuickUnion.LidurD();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("\nWeighted Quick Union + Path Compression: ");
            wQuickUnionPath.LidurD();
            Console.ReadLine();
        }
Example #2
0
        public void LidurD()
        {
            Console.ForegroundColor = ConsoleColor.Red;
            WeightedQuickUnionPathCompression a = new WeightedQuickUnionPathCompression(id.Length);

            for (int i = 0; i < id.Length - 1; i++)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("Tengja " + i + " við " + (i + 1) + ":\t ");
                Console.ForegroundColor = ConsoleColor.Red;

                a.union(i, i + 1);
                a.print();
                Console.WriteLine();
            }
        }