HomeAlgorithms & AIBellman–Ford Algorithm Explained

🧮 Bellman–Ford Algorithm Explained

3D weighted graph, including negative-weight edges, where the sim animates edge relaxation iteration by iteration, with an editable topology and a toggle to introduce a negative cycle and watch the algorithm detect it.

Algorithms & AI3DModerate60 FPS
bellman-ford-explained-lab ↗ Open standalone

A 3D directed weighted graph — including negative-weight edges — where each edge relaxation step animates live, building a shortest-path tree from a golden source node, with a toggle to introduce a negative cycle and watch the algorithm detect it on the extra verification pass.

🔬 What It Demonstrates

Bellman–Ford relaxes every edge in the graph up to V−1 times, updating each node's shortest known distance from the source. A final Vth pass checks whether any edge can still relax — if so, a negative-weight cycle exists and no finite shortest path is defined.

🎮 How to Use

Pick a preset graph, or flip on "Introduce negative cycle" to add a back-edge that creates one. Press Play to auto-run edge relaxations, or Step through them one at a time. Teal edges show the current shortest-path tree; red edges carry negative weight.

💡 Did You Know?

Distance-vector routing protocols like RIP are essentially distributed, gossip-based versions of Bellman–Ford — each router relaxes its known distances using updates from its neighbours, round after round.

⚙ Under the hood

3D weighted graph, including negative-weight edges, where the sim animates edge relaxation iteration by iteration, with an editable topology and a toggle to introduce a negative cycle and watch the algorithm detect it.

bellman-fordshortest-pathgraph-algorithmsnegative-weightsedge-relaxationalgorithms

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)