Answer the question
In order to leave comments, you need to log in
Why doesn't Dijkstra's algorithm work with undirected graphs?
Many sources write that Dijkstra's algorithm does not work with cycles in graphs, but I did not find an explanation
Answer the question
In order to leave comments, you need to log in
> Many sources write
For example?
Wikipedia doesn't have anything like that. There is only a restriction on the non-negativity of the weights.
If you slip a graph with cycles under the classical Dijkstra, then it will go in cycles and never give an answer.
What can you do. That is the algorithm. But on the other side. Why do you need to solve the problem of finding the shortest routes on cycles? Look for a real life example and you will understand that either the abstraction is "wrong" or the wrong algorithm.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question