Bölüm 4.2 · Simülatör

Shortest Path Algorithms

← Bölüm 4.2

Ready.

Shortest Path Algorithms

Generate a connected weighted graph and compare Dijkstra, Bellman-Ford, and Floyd-Warshall from node A to the last node.

How to use

  • Choose the number of nodes (3–10) and press Generate for a new random connected graph.
  • Run one of the three algorithms; the current node is highlighted, relaxed edges flash, and tentative distances appear above the nodes and in the side table.
  • When an algorithm finishes, the shortest path from A to the last node is drawn and its rows are marked in the table.
  • Drag nodes to rearrange the drawing (only while no algorithm is running). Cancel stops a run.

Dijkstra

Efficient for graphs with non-negative edge weights. This simulator therefore generates only positive weights.

Bellman-Ford

Relaxes all edges repeatedly. It can handle negative edges in general, though this shared comparison graph uses positive weights.

Floyd-Warshall

Computes shortest paths between all pairs of vertices using dynamic programming in O(V³) time. The table shows the row for source A after each intermediate node k.

Complexity

AlgorithmTimeNotes
Dijkstra (array)O(V²)O((V + E) log V) with a binary heap
Bellman-FordO(V·E)Detects negative cycles
Floyd-WarshallO(V³)All pairs, O(V²) memory