Skip to content

Instantly share code, notes, and snippets.

View mdsrosa's full-sized avatar

Matheus Rosa mdsrosa

View GitHub Profile
@mdsrosa
mdsrosa / dijkstra.py
Last active April 14, 2016 20:32 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):