简体   繁体   English

最短路径和Dijkstra算法

[英]Shortest Path and Dijkstra Algorithm

I cannot seem to find any indication to this question on the internet and as I am in exams I am running out of time, the question is pretty simple and any explanation would be welcoming(although a simple yes or no will do as well). 我似乎无法在互联网上找到这个问题的任何迹象,因为我在考试中我的时间已经不多了,问题很简单,任何解释都会很受欢迎(虽然简单的是或否也会这样做)。

For Dijkstra's algorithm, must a graph be strongly connected? 对于Dijkstra的算法,图形必须是强连接的吗? That is every vertice can be reached from any other vertice? 那可以从任何其他顶点到达每个顶点? Or is it possible to have vertices that are unreachable and thus you must start at another node using the algorithm? 或者是否有可能无法访问的顶点,因此您必须使用该算法从另一个节点开始?

To add to this question: Does Dijkstra's algorithm only apply to undirected graphs? 添加到这个问题:Dijkstra的算法是否仅适用于无向图? as all the examples in my textbook relate to undirected edges. 因为我教科书中的所有例子都与无向边相关。

An undirected graph is basically just a directed graph, but with bidirectional connections. 无向图基本上只是一个有向图,但具有双向连接。 So no, Dijkstra's can also be applied to directed graphs. 所以,不,Dijkstra的也可以适用于有向图。

For weakly connected graphs, it depends. 对于弱连通图,它取决于。

Say you have graph section A and graph section B. You can go from A into B, but not from B into A. If you start at A and want to find a shortest path into B, Dijkstra's will work. 假设您有图形部分A和图形部分B.您可以从A进入B,但不能从B进入A.如果您从A开始并想要找到进入B的最短路径,Dijkstra将会起作用。 But naturally, you can't start at B and try to find a path to a node at A. 但很自然,你不能从B开始并尝试在A处找到一个节点的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM