It gives you shortest path from a single node to every other node.

https://www.youtube.com/watch?v=_lHSawdgXpI

Make a table to maintain the distances.

Make a list of unvisited nodes.

Start with a node say A and look at its outgoing edges.

Update teh distances in the table and cross off node A.

Then pick the smallest edge from the above visited edges and do the same as you did for A.

Like this go on till you cross off all the vertices from the list of unvisited nodes.

Time Complexity: O ( |E| + |V| log V )

results matching ""

    No results matching ""