A
A
Anther2020-05-09 15:11:19
Algorithms
Anther, 2020-05-09 15:11:19

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

3 answer(s)
Дмитрий, 2020-05-09
@LazyTalent

Потому что алгоритм Дейкстры является "жадным алгоритмом".

L
Lynn «Кофеман», 2020-05-09
@Lynn

> Many sources write
For example?
Wikipedia doesn't have anything like that. There is only a restriction on the non-negativity of the weights.

M
mayton2019, 2020-05-11
@mayton2019

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 question

Ask a Question

731 491 924 answers to any question