Implementation of Dijkstra's algorithm on a generic discrete graph