Improve graph representation, and improve Dijkstra implementation using priority queues