-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
123 lines (84 loc) · 2.01 KB
/
Node.java
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
package assignment1;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Node{
String junction;
Node parent;
double costFromStart;
int plotNum;
ArrayList<Edge> adjencies;
double estimatedCostToGoal;
public Node(String inJunction){
this.junction = inJunction;
this.parent = null;
this.adjencies = new ArrayList<>();
this.costFromStart = 0;
this.estimatedCostToGoal =0;
}
public ArrayList<Edge> getAdjencies() {
return adjencies;
}
public void setAdjencies(ArrayList<Edge> adjencies) {
this.adjencies = adjencies;
}
public int getPlotNum(){
return this.plotNum;
}
public void setPlotNum(int inNum){
this.plotNum = inNum;
}
public Node getParent() {
return parent;
}
public void setParent(Node parent) {
this.parent = parent;
}
public String getJunction() {
return junction;
}
public void setJunction(String junction) {
this.junction = junction;
}
public void addChildren(Edge inEdge){
this.adjencies.add(inEdge);
}
public double getCostFromStart() {
return costFromStart;
}
public void setCostFromStart(double costFromStart) {
this.costFromStart = costFromStart;
}
public Edge findEdge(Node inNode){
for(int i=0;i<this.getAdjencies().size();i++){
if(this.getAdjencies().get(i).target.equals(inNode)){
return this.getAdjencies().get(i);
}
}
return null;
}
public void deleteEdge(){
for(int i=0;i<this.adjencies.size();i++){
if(this.adjencies.get(i).target.junction=="initial"){
this.adjencies.remove(i);
}
if(this.adjencies.get(i).target.junction=="goal"){
this.adjencies.remove(i);
}
}
}
public double getEstimatedCostToGoal(Node goal){
return 0;
}
public double getTotalCost(){
return (this.costFromStart+this.estimatedCostToGoal);
}
// protected List constructPath(Node inNode){
// LinkedList path = new LinkedList();
// while(inNode.parent!=null){
// path.addFirst(inNode);
// inNode = inNode.parent;
// }
// return path;
// }
}