-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
137 lines (89 loc) · 2.44 KB
/
Node.java
File metadata and controls
137 lines (89 loc) · 2.44 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
public class Node<T extends Comparable<T>, S extends Comparable<S>>
implements Comparable<Node<T,S>> {
private T nodeKey;
private S hashNodeKey;
private int degree;
private Node<T,S> parent;
private Node<T,S> child;
private Node<T,S> prev;
private Node<T,S> next;
private boolean isChildCut; //Indicator of Child Cut value for a node
private boolean isMaximum;
public Node() {
setNodeKey(null);
}
public Node(T nodeKey, S hashNodeKey) {
this.setNodeKey(nodeKey);
this.setHashNodeKey(hashNodeKey);
setNodeNext(this);
setNodePrev(this);
}
public T getNodeKey() {
return nodeKey;
}
public S getHashNodeKey() {
return hashNodeKey;
}
public int compareTo(Node<T,S> other) {
return this.getNodeKey().compareTo(other.getNodeKey());
}
public Node<T,S> getNodeChild() {
return child;
}
public void setNodeChild(Node<T,S> child) {
this.child = child;
}
public Node<T,S> getNodeParent() {
return parent;
}
public void setNodeParent(Node<T,S> parent) {
this.parent = parent;
}
public boolean isChildCut() {
return isChildCut;
}
public void setMarked(boolean isChildCut) {
this.isChildCut = isChildCut;
}
public Node<T,S> getNodeNext() {
return next;
}
public void setNodeNext(Node<T,S> next) {
this.next = next;
}
public Node<T,S> getNodePrev() {
return prev;
}
public void setNodePrev(Node<T,S> prev) {
this.prev = prev;
}
public void setNodeKey(T nodeKey) {
this.nodeKey = nodeKey;
}
public void setHashNodeKey(S hashNodeKey) {
this.hashNodeKey = hashNodeKey;
}
int getNodeDegree() {
return degree;
}
public void setNodeDegree(int degree) {
this.degree = degree;
}
public boolean isMaximum() {
return isMaximum;
}
void setMaximum(boolean isMaximum) {
this.isMaximum = isMaximum;
}
void displayNode() {
System.out.println("Node Key:"+this.getNodeKey());
System.out.println("Node Hash Key:"+this.getHashNodeKey());
System.out.println("Node Degree:"+this.getNodeDegree());
System.out.println("Node Child:"+(this.getNodeChild() != null ? this.getNodeChild().getNodeKey() : null));
System.out.println("Node Parent:"+(this.getNodeParent() != null ? this.getNodeParent().getNodeKey() : null));
System.out.println("Node Next:"+(this.getNodeNext() != null ? this.getNodeNext().getNodeKey() : null));
System.out.println("Node Prev:"+(this.getNodePrev() != null ? this.getNodePrev().getNodeKey() : null));
System.out.println("Node isChildCut:"+this.isChildCut());
System.out.println("Node isMaximum:"+this.isMaximum());
}
}