Wrote Dijkstra's algorithm. Hope it works.