src/work/johanna/unionfind_test.cc
changeset 473 2cef25dcde3f
parent 394 3a34c5626e52
child 481 54d8feda437b
equal deleted inserted replaced
0:a36caaa93420 1:ca48e9d9ad9b
    73   check(U.size(4) == 3);
    73   check(U.size(4) == 3);
    74   cout << "size of the class of 5: " << U.size(5) << endl;
    74   cout << "size of the class of 5: " << U.size(5) << endl;
    75   check(U.size(5) == 2);
    75   check(U.size(5) == 2);
    76   cout << "size of the class of 6: " << U.size(6) << endl;
    76   cout << "size of the class of 6: " << U.size(6) << endl;
    77   check(U.size(6) == 1);
    77   check(U.size(6) == 1);
       
    78   cout << "size of the class of 2: " << U.size(2) << endl;
       
    79   check(U.size(2) == 3);
    78 
    80 
    79   cout <<"erase 1: " << endl;
    81   cout <<"erase 1: " << endl;
    80   U.erase(1);
    82   U.erase(1);
    81   print(U);
    83   print(U);
       
    84 
       
    85   cout << "size of the class of 4: " << U.size(4) << endl;
       
    86   check(U.size(4) == 2);
       
    87   cout << "size of the class of 2: " << U.size(2) << endl;
       
    88   check(U.size(2) == 2);
       
    89 
    82 
    90 
    83   cout <<"erase 1: " << endl;
    91   cout <<"erase 1: " << endl;
    84   U.erase(1);
    92   U.erase(1);
    85   print(U);
    93   print(U);
    86 
    94 
    90 
    98 
    91   cout << "split the class of 5: " << endl;
    99   cout << "split the class of 5: " << endl;
    92   U.split(5);
   100   U.split(5);
    93   print(U);
   101   print(U);
    94 
   102 
       
   103 
       
   104   cout << "size of the class of 4: " << U.size(4) << endl;
       
   105   check(U.size(4) == 2);
       
   106   cout << "size of the class of 3: " << U.size(3) << endl;
       
   107   check(U.size(3) == 1);
       
   108   cout << "size of the class of 2: " << U.size(2) << endl;
       
   109   check(U.size(2) == 2);
       
   110 
       
   111 
    95   cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
   112   cout << "Joining 3 - 4 and 2 - 4 ..." << endl;
    96   check(U.join(3,4));
   113   check(U.join(3,4));
    97   check(!U.join(2,4));
   114   check(!U.join(2,4));
    98   print(U);
   115   print(U);
       
   116 
       
   117 
       
   118   cout << "size of the class of 4: " << U.size(4) << endl;
       
   119   check(U.size(4) == 3);
       
   120   cout << "size of the class of 3: " << U.size(3) << endl;
       
   121   check(U.size(3) == 3);
       
   122   cout << "size of the class of 2: " << U.size(2) << endl;
       
   123   check(U.size(2) == 3);
       
   124 
       
   125   cout << "makeRep(4)" << endl;
       
   126   U.makeRep(4);
       
   127   print(U);
       
   128   cout << "makeRep(3)" << endl;
       
   129   U.makeRep(3);
       
   130   print(U);
       
   131   cout << "makeRep(2)" << endl;
       
   132   U.makeRep(2);
       
   133   print(U);
       
   134 
       
   135   cout << "size of the class of 4: " << U.size(4) << endl;
       
   136   check(U.size(4) == 3);
       
   137   cout << "size of the class of 3: " << U.size(3) << endl;
       
   138   check(U.size(3) == 3);
       
   139   cout << "size of the class of 2: " << U.size(2) << endl;
       
   140   check(U.size(2) == 3);
       
   141 
    99 
   142 
   100   cout << "eraseClass 4 ..." << endl;
   143   cout << "eraseClass 4 ..." << endl;
   101   U.eraseClass(4);
   144   U.eraseClass(4);
   102   print(U);
   145   print(U);
   103 
   146