Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am mahadi on github.
* I am mahadi (https://keybase.io/mahadi) on keybase.
* I have a public key ASBVtR9Us_sRFE5_DtOFym5woONJ3ALJo1piD8UVuzXnmAo
To claim this, I am signing this object:
@mahadi
mahadi / dijkstra_3.py
Last active January 4, 2019 23:38
Find all shortest paths using dijkstra
# Dijkstra's algorithm for shortest paths
# David Eppstein, UC Irvine, 4 April 2002
# source http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117228
class priorityDictionary(dict):
def __init__(self):
"""Initialize priorityDictionary by creating binary heap
of pairs (value,key). Note that changing or removing a dict entry will
not remove the old pair from the heap until it is found by smallest() or
until the heap is rebuilt."""