Skip to content

Instantly share code, notes, and snippets.

Avatar

Sofya Tuymedova stuymedova

  • Looking for work
View GitHub Profile
View bellman_ford.py
# Old code initially implemented as part of a proof of concept example
# from "Algorithms Unlocked" by Thomas H. Cormen (see "arbitrage opportunity" p.105)
def bellman_ford(graph, source):
dist = {} # distance
pred = {} # predecessor
# Step 1: initialize the graph
for v in graph:
dist[v] = float('Inf')