Skip to content

Instantly share code, notes, and snippets.

View dematom's full-sized avatar

Motamed Wael dematom

View GitHub Profile
@dematom
dematom / gist:3255003c860a9618f165fceea9b728c8
Created June 30, 2019 19:50 — 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):