Пример #1
0
        public void huiswerk()
        {
            // Arbitrarily preformed -> Union(2,3), union(5,6), union(7,5), union(2,5), union(0,1), union(4,0), union(0,2)
            DisjointSets d_arbit = new DisjointSets(8);
            DisjointSetsSize d_size = new DisjointSetsSize(8);
            DisjointSetsHeight d_height = new DisjointSetsHeight(8);
            //DisjointSetsSize d
            richTextBox1.Visible = true;
            richTextBox1.Dock = DockStyle.Fill;
            d_arbit.Union(2, 3); d_size.Union(2, 3); d_height.Union(2, 3);
            d_arbit.Union(5, 6); d_size.Union(5, 6); d_height.Union(5, 6);
            d_arbit.Union(7, 5); d_size.Union(7, 5); d_height.Union(7, 5);
            d_arbit.Union(2, 5); d_size.Union(2, 5); d_height.Union(2, 5);
            d_arbit.Union(0, 1); d_size.Union(0, 1); d_height.Union(0, 1);
            d_arbit.Union(4, 0); d_size.Union(4, 0); d_height.Union(4, 0);
            d_arbit.Union(0, 2); d_size.Union(0, 2); d_height.Union(0, 2);

            WriteConsole("Created by Wendy & Erik");
            WriteConsole();

            // print the array
            WriteConsole("Preformed arbitrarily");
            WriteConsole("Normal", true);
            WriteConsole(d_arbit.ToStringIndex(), true);
            WriteConsole(d_arbit.ToString(), true);
            WriteConsole();
            WriteConsole("After d_arbit.Find(7)", true);
            d_arbit.Find(7);
            // reprint
            WriteConsole(d_arbit.ToStringIndex(), true);
            WriteConsole(d_arbit.ToString(), true);
            WriteConsole();

            // print the array
            WriteConsole("Performed smart (by size)");
            WriteConsole("Normal", true);
            WriteConsole(d_size.ToStringIndex(), true);
            WriteConsole(d_size.ToString(), true);
            WriteConsole();
            WriteConsole("After d_size.Find(1)", true);
            d_size.Find(1);
            // reprint
            WriteConsole(d_size.ToStringIndex(), true);
            WriteConsole(d_size.ToString(), true);
            WriteConsole();

            // print the array
            WriteConsole("Performed smart (by height)");
            WriteConsole("Normal", true);
            WriteConsole(d_height.ToStringIndex(), true);
            WriteConsole(d_height.ToString(), true);
            WriteConsole();
            WriteConsole("After d_height.Find(1)", true);
            d_height.Find(1);
            // reprint
            WriteConsole(d_height.ToStringIndex(), true);
            WriteConsole(d_height.ToString(), true);
        }
Пример #2
0
 public DisjointSetsSize(DisjointSetsSize ds)
 {
     this.SetArray = ds.SetArray;
 }