Right now I'm performing Dijkstra's algorithm on the entire graph and forming a min-heap of the nodes by total distance from the origin node. I then remove the top n elements from the heap.
This strikes me as seriously inefficient. Suppose I need to find the 10 closest nodes and my graph has over over 100000 nodes. Then performing Dijkstra's on the entire graph seems like a waste of time. But the problem is I'm not sure of any other way I can find the top 10 closest nodes without calculating the shortest path to each and every node in the graph.
Is there a better way?