forked from aamatodev/Covering-TravellingSalesmanProblem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opencity.py
29 lines (20 loc) · 799 Bytes
/
opencity.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
import csv
import numpy as np
from city import City
def openCity(cityfile, populationfile):
cityList = []
node_array = []
with open(cityfile, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=' ')
for row in reader:
node_array.append([float(row[1]), float(row[2])])
fullData = np.array(node_array)
# adjMatrix = calculateADJMatrix(fullData[:, :2])
with open(populationfile, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
population = row
population = np.array(population, dtype='float64')
for i in range(len(fullData)):
cityList.append(City(id=i, x=fullData[i][0], y=fullData[i][1], population=population[i]))
return cityList, population