2013-05-06 82 views
-1
Consider the following matrix/array that contains the distances between 4 cities: 

0 1 2 3 
1 0 4 5 
2 4 0 6 
3 5 6 0 

Each row/column pair (i,j) represents the distance between city i and city j. 
For example the distance between city 1 and city 4 is 3. 

我只是想檢查我的理解是否正確。像陣列,第一個城市從0開始關閉所以在基體中,城市1是0和城市2是1.旅行推銷員:矩陣和旅遊

城市3和城市3將是0之間的路徑?首先我們看一下第2行,然後第2列。

讓我們想象一下,我們有以下游:T = {1,3,2,4}。要工作了這一點,我們做...

市1至3城市爲2。3市城市2是4市2〜4爲5

所以遊的長度應爲2 + 4 + 5 = 11?在旅行商問題然而,我們總是回到行駛到起始位置,所以從城市4,我們必須回到1這將耗費額外的3,所以我們最後的遊覽爲14(11 + 3)。

回答