DijkstraSP Class |
The DijkstraSP class represents a data type for solving the single-source shortest paths problem in edge-weighted digraphs where the edge weights are nonnegative.
This implementation uses Dijkstra's algorithm with a binary heap. The constructor takes time proportional to E log V, where V is the number of vertices and E is the number of edges. Afterwards, the DistTo() and HasPathTo() methods take constant time and the PathTo() method takes time proportional to the number of edges in the shortest path returned.
Namespace: Algs4Net
public class DijkstraSP
The DijkstraSP type exposes the following members.
Name | Description | |
---|---|---|
![]() | DijkstraSP | Computes a shortest-paths tree from the source vertex s to every other
vertex in the edge-weighted digraph G. |
Name | Description | |
---|---|---|
![]() | DistTo |
Returns the length of a shortest path from the source vertex s to vertex v. |
![]() | HasPathTo |
Returns true if there is a path from the source vertex s to vertex v. |
![]() ![]() | MainTest |
Demo test the DijkstraSP data type. |
![]() | PathTo |
Returns a shortest path from the source vertex s to vertex v. |
For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class DijkstraSP implementation by the respective authors.