-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.py
36 lines (29 loc) · 965 Bytes
/
node.py
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
class graph_node:
def __init__(self, neighbors, costs, position):
self.neighbors = neighbors;
self.costs = costs;
self.position = position;
self.parent = None;
self.g = 0; #cost of the path from the start node to this node
self.h = 0; #estimated cost from this node to the end node
self.dimension = len(position);
def get_pos(self):
return self.position;
def get_cost(self):
return self.costs;
def get_neighbors(self):
return self.neighbors;
def get_parent(self):
return self.parent;
def set_parent(self, parent):
self.parent = parent;
return self.parent;
def set_g(self, g):
self.g = g;
return self.g;
def calculate_h(self, end_node_position):
result = 0;
for i in range(1,dim):
result += self.position[i] - end_node_position[i];
self.h = result;
return self.h;