Dijkstra's algorithm: Difference between revisions
→{{header|Java}}
Line 1,196:
This implementation finds the single path from a source to all reachable vertices.
Building the graph from a set of edges takes O(E log V) for each pass.
Vertices are stored in a TreeSet (binary heap) instead of a PriorityQueue (a balanced binary heap) in order to get O(
Decreasing the distance of a vertex is accomplished by removing it from the heap and later re-inserting it.
<lang java>
|