Skip to content

Instantly share code, notes, and snippets.

Avatar

Mana Borwornpadungkitti potpath

View GitHub Profile
@potpath
potpath / dijkstra.py
Last active Jan 11, 2021 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm using heapq
View dijkstra.py
import heapq
from collections import defaultdict
class Graph:
def __init__(self, n):
self.nodes = set(range(n))
self.edges = defaultdict(list)
self.distances = {}