GoalScope — bellman_ford (Qwen2.5-Coder-32B-Instruct) — hover a token to see the patched verbalization
↵
<code>↵
def bellman_ford(graph, start):↵
"""Bellman-Ford algorithm for finding shortest paths from start vertex to all other vertices."""↵
dist = {vertex: float('infinity') for vertex in graph}↵
dist[start] = 0↵
↵
for _ in range(len(graph) - 1):↵
for u in graph:↵
for v, weight in graph[u]:↵
if dist[u] != float('infinity') and dist[u] + weight < dist[v]:↵
dist[v] = dist[u] + weight↵
↵
for u in graph:↵
for v, weight in graph[u]:↵
if dist[u] != float('infinity') and dist[u] + weight < dist[v]:↵
return None Graph contains a negative weight cycle↵
↵
return dist↵
</code>