src/work/johanna/unionfind_test.cc
changeset 482 dce64ce044d6
parent 462 0ab31578af67
equal deleted inserted replaced
1:ca48e9d9ad9b 2:a7db8063892a
    67   check(U.join(1,4));
    67   check(U.join(1,4));
    68   check(!U.join(2,4));
    68   check(!U.join(2,4));
    69   check(U.join(3,5));
    69   check(U.join(3,5));
    70   print(U);
    70   print(U);
    71 
    71 
       
    72   cout << "Inserting 8 to the component of 5 ..." << endl;
       
    73   U.insert(8,5);
       
    74   print(U);
       
    75 
    72   cout << "size of the class of 4: " << U.size(4) << endl;
    76   cout << "size of the class of 4: " << U.size(4) << endl;
    73   check(U.size(4) == 3);
    77   check(U.size(4) == 3);
    74   cout << "size of the class of 5: " << U.size(5) << endl;
    78   cout << "size of the class of 5: " << U.size(5) << endl;
    75   check(U.size(5) == 2);
    79   check(U.size(5) == 3);
    76   cout << "size of the class of 6: " << U.size(6) << endl;
    80   cout << "size of the class of 6: " << U.size(6) << endl;
    77   check(U.size(6) == 1);
    81   check(U.size(6) == 1);
    78   cout << "size of the class of 2: " << U.size(2) << endl;
    82   cout << "size of the class of 2: " << U.size(2) << endl;
    79   check(U.size(2) == 3);
    83   check(U.size(2) == 3);
    80 
    84 
       
    85   cout << "Inserting 9 ..." << endl;
       
    86   U.insert(9);
       
    87   print(U);
       
    88   cout << "Inserting 10 to the component of 9 ..." << endl;
       
    89   U.insert(10,9);
       
    90   print(U);
       
    91 
       
    92   cout << "Joining 8 and 10..." << endl;
       
    93   check(U.join(8,10));
       
    94   print(U);
       
    95 
       
    96   cout << "Move 9 to the class of 4 ..." << endl;
       
    97   check(U.move(9,4));
       
    98   print(U);
       
    99 
       
   100   cout << "Move 9 to the class of 2 ..." << endl;
       
   101   check(!U.move(9,2));
       
   102   print(U);
       
   103 
       
   104   cout << "size of the class of 4: " << U.size(4) << endl;
       
   105   check(U.size(4) == 4);
       
   106   cout << "size of the class of 9: " << U.size(9) << endl;
       
   107   check(U.size(9) == 4);
       
   108   
       
   109   cout << "Move 5 to the class of 6 ..." << endl;
       
   110   check(U.move(5,6));
       
   111   print(U);
       
   112 
       
   113   cout << "size of the class of 5: " << U.size(5) << endl;
       
   114   check(U.size(5) == 2);
       
   115   cout << "size of the class of 8: " << U.size(8) << endl;
       
   116   check(U.size(8) == 3);
       
   117 
       
   118   cout << "Move 7 to the class of 10 ..." << endl;
       
   119   check(U.move(7,10));
       
   120   print(U);
       
   121 
       
   122   cout << "size of the class of 7: " << U.size(7) << endl;
       
   123   check(U.size(7) == 4);
       
   124 
       
   125   cout <<"erase 9: " << endl;
       
   126   U.erase(9);
       
   127   print(U);
       
   128 
    81   cout <<"erase 1: " << endl;
   129   cout <<"erase 1: " << endl;
    82   U.erase(1);
   130   U.erase(1);
    83   print(U);
   131   print(U);
    84 
   132 
    85   cout << "size of the class of 4: " << U.size(4) << endl;
   133   cout << "size of the class of 4: " << U.size(4) << endl;
    94 
   142 
    95   cout <<"erase 6: " << endl;
   143   cout <<"erase 6: " << endl;
    96   U.erase(6);
   144   U.erase(6);
    97   print(U);
   145   print(U);
    98 
   146 
    99   cout << "split the class of 5: " << endl;
   147   cout << "split the class of 8: " << endl;
   100   U.split(5);
   148   U.split(8);
   101   print(U);
   149   print(U);
   102 
   150 
   103 
   151 
   104   cout << "size of the class of 4: " << U.size(4) << endl;
   152   cout << "size of the class of 4: " << U.size(4) << endl;
   105   check(U.size(4) == 2);
   153   check(U.size(4) == 2);