-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
43 lines (33 loc) · 936 Bytes
/
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
import java.util.*;
public class Node {
// Id for readability of result purposes
public String id;
// Parent in the path
public Node parent = null;
public List<Edge> neighbors;
// Evaluation functions
public int FCost = Integer.MAX_VALUE;
public int gCost = Integer.MAX_VALUE;
// Hardcoded heuristic
public int hCost;
Node(int h,String id){
this.hCost = h;
this.id = id;
this.neighbors = new ArrayList<>();
}
public static class Edge {
Edge(int cost, Node node){
this.cost = cost;
this.node = node;
}
public int cost;
public Node node;
}
public void addBranch(int weight, Node node){
Edge newEdge = new Edge(weight, node);
neighbors.add(newEdge);
}
public int calculateHeuristic(Node target){
return this.hCost;
}
}