-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestKTree.cpp
More file actions
63 lines (48 loc) · 1.59 KB
/
TestKTree.cpp
File metadata and controls
63 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include "KTree.h"
int main() {
std::cout << "in main\n";
TreeNode* testNode = new TreeNode();
testNode->setX(7);
std::cout << "getting testnode x " << testNode->getX() << "\n";
int k = 5;
KTree* tree = new KTree(k);
TreeNode* root = new TreeNode();
tree->insert(5,2,root,NULL);
tree->insert(2,2,root,NULL);
tree->insert(7,2,root,NULL);
tree->insert(6,2,root,NULL);
tree->insert(27,2,root,NULL);
tree->insert(1,2,root,NULL);
tree->insert(77,2,root,NULL);
tree->insert(87,2,root,NULL);
tree->insert(187,2,root,NULL);
tree->insert(160,2,root,NULL);
/*
tree->refreshBPQ();
tree->KNN(78,2, root,1);
BPQ* thisbpq78 = tree->getBPQ();
BPQPoint* point78 = thisbpq78->max_priority_elem();
std::cout << "nearest from bpq is (77) " << point78->getX() << "\n";
tree->refreshBPQ();
tree->KNN(72,2, root,1);
BPQ* thisbpq72 = tree->getBPQ();
BPQPoint* point72 = thisbpq72->max_priority_elem();
std::cout << "nearest from bpq is (77) " << point72->getX() << "\n";
tree->refreshBPQ();
tree->KNN(28,2, root,1);
BPQ* thisbpq28 = tree->getBPQ();
BPQPoint* point28 = thisbpq28->max_priority_elem();
std::cout << "nearest from bpq is (27) " << point28->getX() << "\n";
tree->refreshBPQ();
tree->KNN(26,2, root,1);
BPQ* thisbpq26 = tree->getBPQ();
BPQPoint* point26 = thisbpq26->max_priority_elem();
std::cout << "nearest from bpq is (27) " << point26->getX() << "\n";
*/
tree->refreshBPQ();
tree->KNN(14,2, root,1);
BPQ* thisbpq14 = tree->getBPQ();
BPQPoint* point14 = thisbpq14->max_priority_elem();
std::cout << "nearest from bpq is (27) " << point14->getX() << "\n";
}