http://www.cnblogs.com/jiel/p/5852591.html
眾所周知求一個圖的哈密頓回路是一個NPC問題:
In the mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path in an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian path that is a cycle. Determining whether such paths and cycles exist in graphs is the Hamiltonian path problem, which is NP-complete.
(來源於wiki:https://en.wikipedia.org/wiki/Hamiltonian_path)
那么對於這里的-a 選項的問題,我們要求解這個問題的答案,假設我們存在一個多項式算法能夠解決這個問題,並且得到答案{Len,{Station1,Station2,...}},其中Len是經過的最少站點數(重復算多個站點),后面跟着的是經過的站點名稱。那么我們只需要作一個O(1)的判斷:if Len==M print "Yes" else print "No" 即可完成對一個無向圖是否存在哈密頓回路的判斷(M為站點總數)。所以得到結論:存在一個多項式時間復雜度的算法以及一個多項式時間復雜度的轉移,使得判斷哈密頓回路是否存在的問題可以解決。顯然與哈密頓回路是一個NPC問題矛盾。因此不存在一個多項式算法能夠解決這個問題。
不知道這個推導是否正確?如果正確,那我想這個-a 的問題在這里是無法解決的(至少不能判定精確解)。