-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
102 lines (78 loc) · 1.5 KB
/
Copy pathNode.cpp
File metadata and controls
102 lines (78 loc) · 1.5 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <stdio.h>
#include "Node.h"
#include "Vertex.h"
Node::Node() {
this->left = this->dad = this->right = NULL;
}
Node::Node( int key, int parent, double weight ){
this->left = NULL;
this->right = NULL;
this->key = key;
this->dad = NULL;
this->descendents = 0;
this->keyvalue = weight;
this->parent = parent;
}
Node::~Node(){}
void Node::swapKey( Node* first ){
int temp;
double aux;
temp = this->key;
this->key = first->getKey();
first->setKey( temp );
temp = this->parent;
this->parent = first->getParent();
first->setParent( temp );
aux = this->keyvalue;
this->keyvalue = first->getKeyValue();
first->updateKeyValue( aux );
return;
}
void Node::setDescendents( int num ){
this->descendents = num;
}
void Node::setParent( int x ){
this->parent = x;
}
int Node::getParent(){
return this->parent;
}
void Node::updateKeyValue( double newvalue ){
this->keyvalue = newvalue;
}
double Node::getKeyValue(){
return this->keyvalue;
}
int Node::getDescendents(){
return this->descendents;
}
void Node::addDescendent(){
this->descendents++;
}
void Node::subDescendent(){
this->descendents--;
}
Node* Node::getLeft(){
return this->left;
}
Node* Node::getDad(){
return this->dad;
}
Node* Node::getRight(){
return this->right;
}
void Node::setLeft( Node* n ){
this->left = n;
}
void Node::setRight( Node* n ){
this->right = n;
}
void Node::setDad( Node* d ){
this->dad = d;
}
int Node::getKey( ) {
return this->key;
}
void Node::setKey( int mykey ){
this->key = mykey;
}