Skip to content

Instantly share code, notes, and snippets.

View alexhwoods's full-sized avatar

Alex Woods alexhwoods

View GitHub Profile
@alexhwoods
alexhwoods / dijkstra.py
Last active September 26, 2016 21:01
Dijkstra's Algorithm (clean)
# python 3 only!!!
import collections
import math
class Graph:
def __init__(self):
self.vertices = set()
self.edges = collections.defaultdict(list)
self.weights = {}
@alexhwoods
alexhwoods / dijkstra.py
Last active September 26, 2016 20:50
Dijkstra's Algorithm (commented)
# python 3 only!!!
import collections
import math
class Graph:
''' graph class inspired by https://gist.github.com/econchick/4666413
'''
def __init__(self):