def initGraph(self, name):
#file reading using pandas
df = pd.read_excel(name, sheetname='Sheet1')
dim = df['Dimension']
x = df['X']
y = df['Y']
#print x,y
self.numCities = len(dim)
#set and fill the adjMatrix
self.adjMatrix = [[1.0 for i in range(self.numCities)] for j in range(self.numCities) ]
for i in range(self.numCities):
for j in range(self.numCities):
#fill the adjmatrix with city coordinates and calculate euclidean distances
self.adjMatrix[i][j] = self.calEdge(x[i], x[j], y[i], y[j])
#calculating edge weights using euclidean distances
main.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录