calculates the shortest path from a source to each vertex using Dijkstra's algorithm and a binary heap