[JAVA] 最小生成树解决TSP
问题背景:
TSP Problem:
Input: a weighted complete undirected graph G with vertex set
G.V={ v_0,v_(1,)…,v_(n-1)}. The weight of the edge from v_i and v_j is denoted as G.w(i,j). It is assumed that the weights of the edges are non-negative. In other words, the weights satisfy the following constraints:
{ (G.w(i,j)=G.w(j,i); G.w(i,j)>0 if i≠ j; G.w(j,i)=0 if i=j) }
Output: a TSP tour on G which is a Hamiltonian cycle that cycle that starts from v_0, visit each node in G only once and return back to starting vertex〖 v〗_0.
Objective: Minimize the total weight of the edges in the TSP tour.
Heuristics
Minimum Spanning Tree (MST) Based Heuristic
Construct a MST, T, for the vertices in G from starting point v_0;
Traverse around T to get the initial TSP tour for G;
Exploit the triangular inequality and remove unnecessary visits in the TSP tour.
Compute the length of the tour.
Nearest Neighbour (NN) Heuristic
current vertex ← v0;
Loop for n-1 steps
At each step, choose to visit next the vertex that is closest to the current vertex;
Update the current vertex;
Including the closing edge (back to v0) in the tour;
Compute the length of the tour.
求以上两种算法的JAVA代码思路
补充: 1. 自动生成一个随机的N顶点图片的代码已经附上, 问题是如何实现以上两种算法呢. 拜托
TSP Problem:
Input: a weighted complete undirected graph G with vertex set
G.V={ v_0,v_(1,)…,v_(n-1)}. The weight of the edge from v_i and v_j is denoted as G.w(i,j). It is assumed that the weights of the edges are non-negative. In other words, the weights satisfy the following constraints:
{ (G.w(i,j)=G.w(j,i); G.w(i,j)>0 if i≠ j; G.w(j,i)=0 if i=j) }
Output: a TSP tour on G which is a Hamiltonian cycle that cycle that starts from v_0, visit each node in G only once and return back to starting vertex〖 v〗_0.
Objective: Minimize the total weight of the edges in the TSP tour.
Heuristics
Minimum Spanning Tree (MST) Based Heuristic
Construct a MST, T, for the vertices in G from starting point v_0;
Traverse around T to get the initial TSP tour for G;
Exploit the triangular inequality and remove unnecessary visits in the TSP tour.
Compute the length of the tour.
Nearest Neighbour (NN) Heuristic
current vertex ← v0;
Loop for n-1 steps
At each step, choose to visit next the vertex that is closest to the current vertex;
Update the current vertex;
Including the closing edge (back to v0) in the tour;
Compute the length of the tour.
求以上两种算法的JAVA代码思路
补充: 1. 自动生成一个随机的N顶点图片的代码已经附上, 问题是如何实现以上两种算法呢. 拜托
...全文
相关推荐
TSP.rar_A星算法_TSP A星_TSP JAVA_tsp a star_tsp java a star
用A星算法解决TSP问题,其中的择优函数选的是最小生成树
离散数学实验TSP(旅行商问题)的代码实现
离散数学实验(南京航空航天大学) 对于n阶完全带权图,使用以下两种算法获得TSP问题的近似解,并对所得结果进行比较: 1.最邻近法 2.最小生成树法
Java语言TSP递归程序的优化.rar_TSP JAVA_tsp
因为递归程序运行的效率一般都比较低,本程序用java语言来实现TSP递归程序的优化
使用Java实现的基于最小生成树的旅行商问题.zip
旅行商问题 使用Java实现的基于最小生成树的旅行商问题
用java解决TSP问题
该java代码可解决常遇到的TSP问题,十分方便


