Algorithm: shortest path between all points

后端 未结 4 774
小鲜肉
小鲜肉 2021-01-04 07:06

Suppose I have 10 points. I know the distance between each point.

I need to find the shortest possible route passing through all points.

I have tried a coup

4条回答
  •  心在旅途
    2021-01-04 07:52

    This is obviously Travelling Salesman problem. Specifically for N=10, you can either try the O(N!) naive algorithm, or using Dynamic Programming, you can reduce this to O(n^2 2^n), by trading space.

    Beyond that, since this is an NP-hard problem, you can only hope for an approximation or heuristic, given the usual caveats.

提交回复
热议问题