Dijktra算法VS一口气首先寻找图中最短路径 [英] Dijktra algorithm vs breath first search for shortest path in graph

查看:535
本文介绍了Dijktra算法VS一口气首先寻找图中最短路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些澄清和inputts就在向图 Dijktra算法 VS 呼吸优先搜索,如果这是正确的

I need some clarifications and inputts regarding Dijktra's algorithm vs breath first search in directed graphs, if these are correct.

Dijktra的算法可以找到到节点的最短路径节点 A F 权重图,无论是否有循环或没有(只要不存在负权重)的

Dijktra's algorithm finds the shortest path from Node A to Node F in a weighted graph regardless of if there is a cycle or not (as long as there are no negative weights)

但是,从 A到图中的所有其他节点的所有路径的计算,我们抓住从 A 的路径 F 通过反转节点的序列 prev`。

but for that, All paths from A to all other Nodes in the graph are calculated and we grab the path fromAtoFby reversing the sequences of nodes inprev`.

BFS:发现从节点A 的最短路径节点F 在非权图,但如果如果一个周期检测失败。

BFS: finds the shortest path from Node A to Node F in a non-weighted graph, but if fails if a cycle detected.

不过, BFS 刚刚从计算节点A的路径,节点F和不一定节点A的所有路径 如果节点F及早达成,它只是返回的路径。

however, BFS just calculates the path from Node A to Node F and not necessarily all path from Node A. if Node F is reached early, it just returns the path.

推荐答案

Dijkstra算法不搜索图的所有节点。当它发现从A办法F和肯定没有较短的(因为已经访问节点的外部边界较远),它停止。这是可能的,而不负权重

Dijkstra doesn't search all nodes of the graph. When it has found a way from A to F and is sure there is no shorter one (because the outer border of the already visited nodes is farther away), it stops. This is possible without negative weights.

因此​​,要回答你的问题:如果这是正确的:他们不是

So to answer your question "if these are correct": They are not.

这篇关于Dijktra算法VS一口气首先寻找图中最短路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆