Skip to content

Instantly share code, notes, and snippets.

@alexgolec
Created September 2, 2019 02:48
Show Gist options
  • Save alexgolec/142501dca248bf05f142b900da6110a3 to your computer and use it in GitHub Desktop.
Save alexgolec/142501dca248bf05f142b900da6110a3 to your computer and use it in GitHub Desktop.
def add_conversion(self, orig, dest, rate):
'Insert a conversion into the graph. Note we insert its inverse also.'
if orig not in self.graph:
self.graph[orig] = {}
self.graph[orig][dest] = rate
if dest not in self.graph:
self.graph[dest] = {}
self.graph[dest][orig] = 1.0 / rate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment