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

发布于 2024-07-17 04:56:25 字数 1003 浏览 4 评论 0原文

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

例如:

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

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

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

该路径中有两次重复访问。 更糟糕的路径是在第一个路口左转,然后在三个已经访问过的方块上原路返回。

我不关心结束节点,但开始节点很重要。

谢谢。

编辑:

我在问题中添加了图片,但在查看时看不到它们。 它们是:

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

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

此外,在图表中我需要这个,因为永远不会出现最小重复次数 = 0 的情况。也就是说,要踏上地图中的每个图块,玩家必须至少穿过自己的路径一次。

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长途伴 2024-07-24 04:56:25

你的措辞很糟糕——它可以简化为 NP 完全问题。 如果你可以最大限度地减少重复访问,那么你可以将它们推到 0,然后你就会有一个 哈密尔顿循环。 这是可以解决的,但很难。

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.

守护在此方 2024-07-24 04:56:25

这听起来像是可以映射到旅行商问题上……因此很可能最终是 NP 完全问题,并且不知道有效的确定性算法。

寻找路径相当简单——找到一个(或最小)生成子树,然后进行深度/广度优先遍历。 找到最佳路线是真正困难的一点。

您可以使用其中一种动态优化技术来尝试并收敛到一个相当好的解决方案。

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

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文