Algorithms, Programming, Interview, Python.
import math def getPath(parent, vertex): if vertex < 0: return [] return getPath(parent, parent[vertex]) + [vertex] def bellmanFord(edges, source, n): distance = [math.inf] * n parent = [-1] * n distance[source] = 0 for k in range(n - 1): for (u, v, w) in edges: if distance[u] != math.inf and