Grafalgo
Library of useful data structures and algorithms
|
00001 00009 #include "DheapSet.h" 00010 #include "Utest.h" 00011 00012 using namespace grafalgo; 00013 00014 void basicTests() { 00015 DheapSet hs(20,3); string s; 00016 00017 cout << "writing empty heap: " << hs.toString(1,s) << endl; 00018 cout << "starting insertions\n"; 00019 for (int i = 1; i <= 20; i++) { 00020 cout << "inserting " << i << " " << (i*7)%13 << endl; 00021 hs.insert(i,(i*7)%13,1); 00022 cout << hs.toString(1,s) << endl; 00023 } 00024 cout << "starting changeKeyMins\n"; 00025 for (int i = 1; i <= 10; i++) { 00026 int j = hs.findMin(1); 00027 cout << "changing key of " << j << " to " 00028 << (i*11)%23 << endl; 00029 hs.changeKeyMin((i*11)%23,1); 00030 cout << hs.toString(1,s) << endl; 00031 } 00032 cout << "starting deleteMins\n"; 00033 for (int i = 1; i <= 15; i++) { 00034 int j = hs.deleteMin(1); 00035 cout << j << " " << hs.toString(1,s) << endl; 00036 } 00037 } 00038 00042 int main() { 00043 cout << "running basic tests\n"; 00044 basicTests(); 00045 cout << "basic tests passed\n"; 00046 00047 // add more systematic tests for each individual method 00048 }