Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 迪克斯特拉’;s最短路径算法_Algorithm_Dijkstra_Shortest Path - Fatal编程技术网

Algorithm 迪克斯特拉’;s最短路径算法

Algorithm 迪克斯特拉’;s最短路径算法,algorithm,dijkstra,shortest-path,Algorithm,Dijkstra,Shortest Path,下面是我们的教授给我们的算法总结 步骤3中提到的图中节点的父节点是什么?我有点困惑,因为我认为节点只有邻居而没有父节点 我的第二个问题是关于第3步,“在堆栈中拾取索引的第条记录”。由于堆栈只允许您查看顶部,我不确定拾取索引的第条记录意味着什么 Dijkstra的最短路径: Step 0: if s == d, stop. Step 1: current node c= s, c.length = 0, stack.push (c, its length, and parent).

下面是我们的教授给我们的算法总结

步骤3中提到的图中节点的父节点是什么?我有点困惑,因为我认为节点只有邻居而没有父节点

我的第二个问题是关于第3步,“在堆栈中拾取索引的第条记录”。由于堆栈只允许您查看顶部,我不确定拾取索引的第条记录意味着什么

Dijkstra的最短路径:

Step 0: if s == d, stop.
Step 1: current node c= s, c.length = 0, stack.push (c, its length, and parent). 
        If u is the source s then no need for parent.
Step 2: min = 0, hop = infinite, index = 1
Step 3: pick up the index’th record in stack, say node u, its length u.length, 
        and its parent w.
Step 4: find a neighbor of u in the table of neighbors, say v, such that v is 
        not found in any item in stack and <u,v> +u.length< hop. 
Step 5: if such a neighbor is found, hop=min=u.length + <u,v> and record_node = v
Step 6: go to step 4 until all the neighbors of u have been tried (all can be 
        found in stack).
Step 7: index ++, go to step 3 until all the nodes have been tried (found in 
        stack).
Step 8: c = record_node, c.length = min, stack_push(c, c.length, u). If c == d 
        stop the entire process and goes to step 9 for data collection, 
        otherwise go to step 2.
Step 9: (t, d.length, and t.parent) = (d, d.length, and d.parent) in stack, 
        keep searching on (t.parent, t.parent.length, t.parent.parent), 
        until t.parent = s.
步骤0:如果s==d,则停止。
步骤1:当前节点c=s,c.length=0,stack.push(c,其长度和父节点)。
如果u是源s,则不需要父级。
步骤2:min=0,hop=无穷,index=1
步骤3:提取堆栈中索引的第条记录,比如节点u,其长度u.length,
它的父母w。
第四步:在邻居表中找到一个u的邻居,比如说v,这样v就是
在堆栈和+u.length
也许可以帮你

我强烈建议大家只需在互联网上浏览一下,就可以更好地解释这个算法。它是当今导航软件最常用的算法——每个主要的导航公司都使用它(可能还有小公司)。它也被用作游戏中的寻路算法


在图中,节点只有邻居,但在运行Dijkstra算法时,您会构建一棵“树”,描述从起始节点到原始图中所有节点的最短路径

在算法运行开始时,所有节点都将其前置节点设置为null,并且在每次迭代中,将父节点设置为通向最短路径的节点

看看这个,注意算法的结果实际上是图的一个子树


希望回答您的问题:)

父节点指的是路径上的节点,比您当前正在检查的节点早一步。换句话说:路径是一个有向图,其中除第一个和最后一个节点外,每个节点的顺序为2(即,它通过边连接到其他两个节点)。节点的父节点是该节点的前置节点


关于堆栈:可能这不是一个真正的堆栈,只是一个将节点推到其上的结构;然后可以索引此结构上的所有节点,而不仅仅是顶部的节点。但是我同意,stack不是一个好的词汇选择。

你有没有试着和你的教授讨论过这些问题?既然他给了你这个算法,他可能会解释得最清楚。是的,我问过了。不幸的是,语言障碍导致了一个问题。我希望对算法有深入了解的人能够识别出他想要传达的内容。谢谢。太可怕了(我指的是总结)。在Wikipedia页面或类似的资源中了解算法,这里没有详细描述。算法本身并不难掌握,有很好的解释。你看过这里了吗?