-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNVertex.java
More file actions
101 lines (85 loc) · 2.3 KB
/
NVertex.java
File metadata and controls
101 lines (85 loc) · 2.3 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
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
/**
* NVertex.java
*
* A n-th dimensional vertex.
*/
public class NVertex{
/* Immutable components of the vertex. This list is public. */
public List<Double> components;
/* Indicates current weight relative to source */
private double relativeWeight;
/* Points to the MST parent vertex */
private NVertex parent;
/* Position in data structure. Used for quick heap lookup */
private int position;
/* Unique id, used for relationship with heap */
private int id;
/**
* Costructs a Vertex from a list of component values. Note that
* the resulting component list is immutable.
*/
public NVertex(List<Double> components) {
// List must contain a positive amount of numbers
if (components == null) {
throw new NullPointerException();
} /*else if (components.size() < 1) {
throw new IllegalArgumentException();
}*/
this.components = Collections.unmodifiableList(
new ArrayList<Double>(components));
this.parent = null;
// relative weight value over max of 1
this.relativeWeight = 100.0;
}
/**
* Getter method for relative weight to source
*/
public double getRelativeWeight() {
return this.relativeWeight;
}
/**
* Setter method for relative weight to source
*/
public void setRelativeWeight(double weight) {
this.relativeWeight = weight;
}
/**
* Getter method for mst parent
*/
public NVertex getParent() {
return this.parent;
}
/**
* Setter method for mst parent
*/
public void setParent(NVertex parent) {
this.parent = parent;
}
/**
* Getter method for vertex position in heap implementation
*/
public int getPosition(){
return this.position;
}
/**
* Setter method for vertex position in heap implementation
*/
public void setPosition(int newPosition){
this.position = newPosition;
}
/**
* Getter method for vertex ID
*/
public int getID() {
return this.id;
}
/**
* Setter method for vertex ID
*/
public void setID(int id){
this.id = id;
}
}