DEV Community

Cover image for Dijkstra Algorithm Greedy Method
He Codes IT
He Codes IT

Posted on

Dijkstra Algorithm Greedy Method

Dijkstra Algorithm Greedy Method is a greedy algorithm that solves the single-source shortest path problem for a directed graph G = (V, E) with nonnegative edge weights, i.e., w (u, v) ≥ 0 for each edge (u, v) ∈ E. For the Definition and more visit HERE

Greedy Approach: Maintain a set of Explored Nodes S for which algorithm has determined d[u] = length of shortest s->u path.

Initialize S = {s}, d[s] = 0
Repeatedly Choose Unexplored node v does not belong S which minimizes
Pie(v) = min ( d[u] + le )

add v to S, and set d[v] = Pie(v).
To recover path, set pred[v] = e that achieves min.
Example for Dijkstra Algorithm Greedy Method

To read more visit https://hecodesit.com/dijkstra-algorithm-greedy-method/

Top comments (0)