# Algorithm: Bellman-Ford Algorithm # Type: Single-Source Shortest Path, Dynamic Programming / Relaxation # Time Complexity: O(V * E) # Space Complexity: O(V) function BellmanFord(graph, V, edges, start): create dist array of size V, initialize with infinity dist[start] = 0 for i from 1 to V-1: for each edge (u, v, weight) in edges: if dist[u] + weight < dist[v]: dist[v] = dist[u] + weight // Check for negative-weight cycles for each edge (u, v, weight) in edges: if dist[u] + weight < dist[v]: return "Graph contains negative weight cycle" return dist