-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertex.py
72 lines (54 loc) · 1.97 KB
/
Vertex.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
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
class Vertex:
def __init__(self, identity, x, y, value=float('inf')):
self.__identity = identity
self.__x = x
self.__y = y
self.__adjacent_vertice = []
self.__value = value
self.__prev = None
# description get and set for all enteries def init
def get_id(self):
return self.__identity
def set_id(self, id):
self.__identity = id
def get_y(self):
return self.__y
def set_y(self, y):
self.__y = y
def get_x(self):
return self.__x
def set_x(self, x):
self.__x = x
def get_value(self):
return self.__value
def set_value(self, value):
self.__value = value
def get_adjacent_vertice(self):
return self.__adjacent_vertice
def append_adjacent_vertice(self, neighbor):
self.__adjacent_vertice.append(neighbor)
def get_prev(self):
return self.__prev
def set_prev(self, prev):
self.__prev = prev
# checked Vertice for is big or small
def __eq__(self, other):
return other.__identity == self.__identity
def __gt__(self, other):
if not isinstance(other, Vertex):
raise TypeError(str(other) + 'is not and instance of ' + self.__class__.__name__)
return self.__value < other.__value
def __lt__(self, other):
if not isinstance(other, Vertex):
raise TypeError(str(other) + 'is not and instance of ' + self.__class__.__name__)
return other.__value > self.__value
def __ge__(self, other):
if not isinstance(other, Vertex):
raise TypeError(str(other) + 'is not and instance of ' + self.__class__.__name__)
return self.__value <= other.__value
def __le__(self, other):
if not isinstance(other, Vertex):
raise TypeError(str(other) + 'is not and instance of ' + self.__class__.__name__)
return other.__value >= self.__value
def __str__(self):
return str(self.__identity)