-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.java
More file actions
37 lines (29 loc) · 894 Bytes
/
Copy pathVertex.java
File metadata and controls
37 lines (29 loc) · 894 Bytes
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
import java.util.ArrayList;
public class Vertex {
int VertexNum;
public String name;
Vertex myvertices;
public static final int NEW = 0;
public static final int VISITED = 2;
public int state = NEW;
public double cost = Double.MAX_VALUE;
public char data;
public AdjacentNode adj;
public int parentIndex = -1;
public int compareTo(Vertex other) {
if (cost < other.cost) {
return -1;
}
if (cost > other.cost) {
return 1;
}
return 0;
}
public void addAdjacentVertex(AdjacentNode adj) {
this.adj = adj;
}
public void updateCost(int newCost, int parentIndex) {
this.cost = newCost;
this.parentIndex = parentIndex;
}
}