Djikstras Algorithm if it doesn't exist a path

561 Views Asked by At

I wonder if you have a source and a target vertice and that I want to find the shortest path between them. My question is it doesn't exist a path between source and target vertrice what will happen then in Djikstras Algorithm will this algorithm discover it?

Djikstra's Algorithm

1

There are 1 best solutions below

1
On BEST ANSWER

The algorithm will eventually run out of possible paths to check, determining that it is not possible: the distance to the target vertice would still be infinity, as it was initialized.

Not necessarily the best way to determine this, though.