The Graph Data Structure

This is a continuation of the graph algorithms, but since they are more complex and different, they have been separated out to a different panel of the webpage

Shortest Path User Guide

Dijkstra Algorithm

With a generated graph, press the Dijkstra button to perform a full Dijkstra algorithm run on the graph. The weights are listed at the bottom and a table with the shortest paths is updated below the canvas.
Dijkstra's algorithm is a greedy algorithm used to find the shortest path from a starting source node to all other nodes in a weighted graph. It works by iteratively selecting the unvisited node with the smallest distance from the source, then updating the distances of its unvisited neighbors if a shorter path is found through the current node. This process continues until all reachable nodes have been visited and their shortest distances from the source are determined. Dijkstra's algorithm is efficient for graphs with non negative edge weights and is widely used in applications like network routing and GPS navigation

Bellman Ford Algorithm

With a generated graph, press the Bellman Ford button to perform a full shortest path search. The weights are located at the bottom of the canvas, and the table is updated below it as well. I have sped up the animation for this algorithm to match its speed with Dijkstra.
The Bellman Ford algorithm is a shortest path algorithm that calculates the shortest distances from a single source vertex to all other vertices in a weighted graph. It's particularly useful because it can handle graphs with negative edge weights, a capability that many other shortest path algorithms like Dijkstra's algorithm lack. The algorithm works by repeatedly relaxing all the edges in the graph |V|-1 times, updating shortest path estimates as shorter paths are discovered. A significant advantage of Bellman Ford is its ability to detect negative weight cycles in a graph, which if present, indicate that no shortest path exists, as one can infinitely decrease the path length by traversing the cycle. However, since it scans every vertex regardless, it is significantly slower than Dijkstra