Python, Programming, Algorithms, Interview.
range(N): for (src, des, weight) in edges: if((d[src] != math.inf) and (d[src] + weight < d[des])): d[des] = d[src] + weight return d[0:N] def JohnsonAlgorithm(graph): edges = [] for i in range(len(graph)): for j in range(len(graph[i])): if graph[i][j] != 0: edges.append([i, j, graph[i][j]]) #