src/work/johanna/unionfind_test.cc
changeset 481 54d8feda437b
parent 462 0ab31578af67
     1.1 --- a/src/work/johanna/unionfind_test.cc	Thu Apr 29 16:30:39 2004 +0000
     1.2 +++ b/src/work/johanna/unionfind_test.cc	Thu Apr 29 16:45:40 2004 +0000
     1.3 @@ -69,15 +69,63 @@
     1.4    check(U.join(3,5));
     1.5    print(U);
     1.6  
     1.7 +  cout << "Inserting 8 to the component of 5 ..." << endl;
     1.8 +  U.insert(8,5);
     1.9 +  print(U);
    1.10 +
    1.11    cout << "size of the class of 4: " << U.size(4) << endl;
    1.12    check(U.size(4) == 3);
    1.13    cout << "size of the class of 5: " << U.size(5) << endl;
    1.14 -  check(U.size(5) == 2);
    1.15 +  check(U.size(5) == 3);
    1.16    cout << "size of the class of 6: " << U.size(6) << endl;
    1.17    check(U.size(6) == 1);
    1.18    cout << "size of the class of 2: " << U.size(2) << endl;
    1.19    check(U.size(2) == 3);
    1.20  
    1.21 +  cout << "Inserting 9 ..." << endl;
    1.22 +  U.insert(9);
    1.23 +  print(U);
    1.24 +  cout << "Inserting 10 to the component of 9 ..." << endl;
    1.25 +  U.insert(10,9);
    1.26 +  print(U);
    1.27 +
    1.28 +  cout << "Joining 8 and 10..." << endl;
    1.29 +  check(U.join(8,10));
    1.30 +  print(U);
    1.31 +
    1.32 +  cout << "Move 9 to the class of 4 ..." << endl;
    1.33 +  check(U.move(9,4));
    1.34 +  print(U);
    1.35 +
    1.36 +  cout << "Move 9 to the class of 2 ..." << endl;
    1.37 +  check(!U.move(9,2));
    1.38 +  print(U);
    1.39 +
    1.40 +  cout << "size of the class of 4: " << U.size(4) << endl;
    1.41 +  check(U.size(4) == 4);
    1.42 +  cout << "size of the class of 9: " << U.size(9) << endl;
    1.43 +  check(U.size(9) == 4);
    1.44 +  
    1.45 +  cout << "Move 5 to the class of 6 ..." << endl;
    1.46 +  check(U.move(5,6));
    1.47 +  print(U);
    1.48 +
    1.49 +  cout << "size of the class of 5: " << U.size(5) << endl;
    1.50 +  check(U.size(5) == 2);
    1.51 +  cout << "size of the class of 8: " << U.size(8) << endl;
    1.52 +  check(U.size(8) == 3);
    1.53 +
    1.54 +  cout << "Move 7 to the class of 10 ..." << endl;
    1.55 +  check(U.move(7,10));
    1.56 +  print(U);
    1.57 +
    1.58 +  cout << "size of the class of 7: " << U.size(7) << endl;
    1.59 +  check(U.size(7) == 4);
    1.60 +
    1.61 +  cout <<"erase 9: " << endl;
    1.62 +  U.erase(9);
    1.63 +  print(U);
    1.64 +
    1.65    cout <<"erase 1: " << endl;
    1.66    U.erase(1);
    1.67    print(U);
    1.68 @@ -96,8 +144,8 @@
    1.69    U.erase(6);
    1.70    print(U);
    1.71  
    1.72 -  cout << "split the class of 5: " << endl;
    1.73 -  U.split(5);
    1.74 +  cout << "split the class of 8: " << endl;
    1.75 +  U.split(8);
    1.76    print(U);
    1.77  
    1.78