【问题标题】:What is the shortest path to explore some points探索某些点的最短路径是什么
【发布时间】:2015-03-22 04:03:38
【问题描述】:

图中有 N 个点,每个点都有一条到其他 (N-1) 个点的路径,并带有成本(例如,成本是线距离或曼哈顿距离)。

对于任意点 A、B、C,有两个约束:

成本(A->B) C) + 成本(C->B)

成本(A->B) == 成本(B->A)

现在,我要做的是找到探索图中所有点的最短路径。方法是什么?或者这个问题没有推进方法。

我有一个想法,假设A是起点,我们尝试找到离A最近的点(假设是B),然后我移动到B点。我尝试找到离B最近的点(A 已被删除)再次,直到我探索所有点。

【问题讨论】:

    标签: algorithm search artificial-intelligence


    【解决方案1】:

    听起来像Dijkstra's algorithm.

    总结链接:

    Start at an arbitrary source node. 
    Set the distance between this node and all other nodes = +Infinity
    Set the distance between this node and itself to, well, 0 :)
    Iterate:
        Mark this node as 'visited'
        Find the distance between this node and its directly connected neighbors
        Update their distances if smaller 
        Go to the next unvisited neighbor which has the smallest distance from the source
         If no neighbors are unvisited, go back a step until you can find an unvisited neighbor. 
         If all neighbors of all nodes are visited, terminate.  
    

    现在您有了一个完整填充的表,其中包含从源到每个节点的距离。选择最小值以找到最佳路径。还要注意,使用完全连接的图遵循这个算法也会给你最小的生成树,我相信,因为它总是会选择两个节点之间的最小距离,而不重复任何。

    【讨论】:

    • 答案是正确的。 +1。但是,您需要用更多细节来扩展这个答案,并提及 Bellman Ford。
    • 但是我为图中的任意两个点提供了一条直接路径。我觉得条件比较宽松。
    • 在你提到之前,我实际上并不知道Bellman-Ford,谢谢。基于看到最短路径这个词,我的思绪直接进入了 Dijkstra。
    猜你喜欢
    • 2016-01-20
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 2022-01-06
    相关资源
    最近更新 更多