algorithm - Dijkstra with Parallel edges and self-loop -
if have weighted undirected graph no negative weights, can contain multiple edges between vertex , self-loops, can run dijkstra algorithm without problem find minimum path between source , destination or exists counterexample?
my guess there not problem, want sure.
if you're going run dijkstra's algorithm without making changes graph, there's chance you'll not shortest path between source , destination.
for example, consider s , o. now, finding shortest path depends on edge being being traversed when want push o queue. if code picks edge weight 1, you're fine. if code picks edge weight 8, algorithm going give wrong answer.
this means algorithm's correctness dependent on order of edges entered in adjacency list of source node.
Comments
Post a Comment