Dijkstra Single-Source Shortest Path

When visualizing networks, different graph traversal algorithms are needed. Implementing the Dijkstra algorithm is intended to review techniques that any computer science student already knows.

Description

If the weights are positive, the Dijkstra algorithm solves the single-source shortest path problem. The implementation requires a priority queue.

Main Idea

Remarks

Note:

Select and click a node to start a traversal. Click the background to reset. Depth is measured using the weights of the edges and visualized using colors. Nodes of the same color are at the same distance from the selected source node. You can select a breadth-first traversal to compare the results. The numbers at the edges are the corresponding weights.



The JavaScript Code