-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmaps.py
194 lines (159 loc) · 6.12 KB
/
maps.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
try:
from data_structs import Node
except ImportError:
msg = "Unable to import Node package from data_structs"
raise ImportError(msg)
__author__ = 'Biney Kingsley'
'''This class only handles all maps to be used in implementing the search algorithms'''
class Maps:
def __init__(self, x_list=None, y_list = None, labels = None, tree = None):
self.x_list = x_list
self.y_list = y_list
self.labels = labels
self.tree = tree
# empty list for plot coordinates and labels
def reset(self):
self.x_list = []
self.y_list = []
self.labels = []
# create original map
def original_map(self):
x = Node("Accra", 0, 200)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert(None, x, 'LEFT')
x = Node("Tema", 40, 120)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Accra", x, 'LEFT')
x = Node("Achimota", 80, 180)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Accra", x, 'RIGHT')
x = Node('Dansoman', 80, 120)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Achimota", x, 'LEFT')
x = Node('Kaneshie', 60, 80)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Dansoman", x, 'LEFT')
x = Node('Mamprobi', 100, 80)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Dansoman", x, 'RIGHT')
x = Node('Kasoa', 100, 160)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Achimota", x, 'RIGHT')
x = Node('Boduase', 140, 140)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Kasoa", x, 'LEFT')
x = Node('Mankessim', 140, 180)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Kasoa", x, 'RIGHT')
return self.x_list, self.y_list, self.labels, self.tree
# create extended map
def extended_map(self):
x = Node("Accra", 0, 200)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert(None, x, 'LEFT')
x = Node("Tema", 40, 120)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Accra", x, 'LEFT')
x = Node("Achimota", 80, 180)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Accra", x, 'RIGHT')
x = Node('Dansoman', 80, 120)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Achimota", x, 'LEFT')
x = Node('Kaneshie', 60, 80)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Dansoman", x, 'LEFT')
x = Node('Bubuashie', 20, 40)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert('Kaneshie', x, 'LEFT')
x = Node('Tesano', 60, 20)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert('Bubuashie', x, 'RIGHT')
x = Node('Mamprobi', 100, 80)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Dansoman", x, 'RIGHT')
x = Node('Russia', 160, 80)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert('Mamprobi', x, 'RIGHT')
x = Node('Korle Gono', 100, 40)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert('Mamprobi', x, 'LEFT')
x = Node('James Town', 120, 20)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert('Korle Gono', x, 'RIGHT')
x = Node('Kasoa', 100, 160)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Achimota", x, 'RIGHT')
x = Node('Boduase', 140, 140)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Kasoa", x, 'LEFT')
x = Node('Mankessim', 140, 180)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Kasoa", x, 'RIGHT')
x = Node('Cape Coast', 180, 200)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Mankessim", x, 'LEFT')
x = Node('Elmina', 200, 160)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Cape Coast", x, 'RIGHT')
x = Node('Kakum', 180, 100)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Elmina", x, 'LEFT')
x = Node('Takoradi', 200, 40)
self.x_list.append(x.get_x())
self.y_list.append(x.get_y())
self.labels.append(x.getKey())
self.tree.insert("Elmina", x, 'RIGHT')
return self.x_list, self.y_list, self.labels, self.tree