访问图表中的所有节点,重复访问次数最少

时间:2023-02-01 16:13:43

I have a tile based map where several tiles are walls and others are walkable. the walkable tiles make up a graph I would like to use in path planning. My question is are their any good algorithms for finding a path which visits every node in the graph, minimising repeat visits?

我有一个基于图块的地图,其中几个瓷砖是墙壁,其他瓷砖是可步行的。可行走的瓷砖构成了我想在路径规划中使用的图形。我的问题是他们是否有任何好的算法来查找访问图中每个节点的路径,从而最大限度地减少重复访问?

For example:

map example http://img220.imageshack.us/img220/3488/mapq.png

地图示例http://img220.imageshack.us/img220/3488/mapq.png

If the bottom yellow tile is the starting point, the best path to visit all tiles with least repeats is:

如果底部黄色图块是起点,则访问所有具有最少重复的图块的最佳路径是:

path example http://img222.imageshack.us/img222/7773/mapd.png

路径示例http://img222.imageshack.us/img222/7773/mapd.png

There are two repeat visits in this path. A worse path would be to take a left at the first junction, then backtrack over three already visited tiles.

在这条道路上有两次重复访问。更糟糕的路径是在第一个交叉路口左转,然后回溯三个已经访问过的地块。

I don't care about the end node but the start node is important.

我不关心终端节点,但起始节点很重要。

Thanks.

Edit:

I added pictures to my question but cannot see them when viewing it. here they are:

我在我的问题中添加了图片,但在查看时无法看到它们。他们来了:

http://img220.imageshack.us/img220/3488/mapq.png

http://img222.imageshack.us/img222/7773/mapd.png

Additionally, in the graphs I need this for there will never be a situation where min repeats = 0. That is, to step on every tile in the map the player must cross his own path at least once.

另外,在图中我需要这个,因为永远不会出现min重复= 0的情况。也就是说,为了踩到地图中的每个图块,玩家必须至少穿过他自己的路径一次。

2 个解决方案

#1


Your wording is bad -- it allows a reduction to an NP-complete problem. If you could minimize repeat visits, then could you push them to 0 and then you would have a Hamiltonian Cycle. Which is solvable, but hard.

你的措辞很糟糕 - 它可以减少NP完全问题。如果你可以最小化重复访问,那么你可以将它们推到0然后你将有一个汉密尔顿循环。这是可以解决的,但很难。

#2


This sounds like it could be mapped onto the traveling salesman problem ... and so likely ends up being NP complete and no efficient deterministic algorithm is known.

这听起来像是可以映射到旅行商问题上......因此很可能最终成为NP完成且没有有效的确定性算法。

Finding a path is fairly straight forward -- find a (or the minimum) spanning subtree and then do a depth/breadth-first traversal. Finding the optimal route is the really difficult bit.

找到一条路径是相当直接的 - 找到一个(或最小的)跨越子树,然后进行深度/广度优先遍历。寻找最佳路线是非常困难的一点。

You could use one of the dynamic optimization techniques to try and converge on a fairly good solution.

您可以使用其中一种动态优化技术来尝试并聚合一个相当不错的解决方案。

Unless there is some attribute of the minimum spanning subtree that could be used to generate the best path ... but I don't remember enough graph theory for that.

除非最小生成子树的某些属性可用于生成最佳路径......但我不记得足够的图论。

#1


Your wording is bad -- it allows a reduction to an NP-complete problem. If you could minimize repeat visits, then could you push them to 0 and then you would have a Hamiltonian Cycle. Which is solvable, but hard.

你的措辞很糟糕 - 它可以减少NP完全问题。如果你可以最小化重复访问,那么你可以将它们推到0然后你将有一个汉密尔顿循环。这是可以解决的,但很难。

#2


This sounds like it could be mapped onto the traveling salesman problem ... and so likely ends up being NP complete and no efficient deterministic algorithm is known.

这听起来像是可以映射到旅行商问题上......因此很可能最终成为NP完成且没有有效的确定性算法。

Finding a path is fairly straight forward -- find a (or the minimum) spanning subtree and then do a depth/breadth-first traversal. Finding the optimal route is the really difficult bit.

找到一条路径是相当直接的 - 找到一个(或最小的)跨越子树,然后进行深度/广度优先遍历。寻找最佳路线是非常困难的一点。

You could use one of the dynamic optimization techniques to try and converge on a fairly good solution.

您可以使用其中一种动态优化技术来尝试并聚合一个相当不错的解决方案。

Unless there is some attribute of the minimum spanning subtree that could be used to generate the best path ... but I don't remember enough graph theory for that.

除非最小生成子树的某些属性可用于生成最佳路径......但我不记得足够的图论。