Click or drag to resize
BreadthFirstDirectedPaths Class

The BreadthDirectedFirstPaths class represents a data type for finding shortest paths (number of edges) from a source vertex S (or set of source vertices) to every other vertex in the digraph.

This implementation uses breadth-first search. The constructor takes time proportional to V + E, where V is the number of vertices and E is the number of edges. It uses extra space (not including the digraph) proportional to V.

Inheritance Hierarchy
SystemObject
  Algs4NetBreadthFirstDirectedPaths

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class BreadthFirstDirectedPaths

The BreadthFirstDirectedPaths type exposes the following members.

Constructors
  NameDescription
Public methodBreadthFirstDirectedPaths(Digraph, IEnumerableInt32)
Computes the shortest path from any one of the source vertices in sources to every other vertex in graph G.
Public methodBreadthFirstDirectedPaths(Digraph, Int32)
Computes the shortest path from s and every other vertex in graph G.
Top
Methods
  NameDescription
Public methodDistTo
Returns the number of edges in a shortest path from the source s (or sources) to vertex v?
Public methodHasPathTo
Is there a directed path from the source s (or sources) to vertex v?
Public methodStatic memberMainTest
Demo test the BreadthFirstDirectedPaths data type.
Public methodPathTo
Returns a shortest path from s (or sources) to v, or null if no such path.
Top
Remarks

For additional documentation, see Section 4.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class BreadthFirstDirectedPaths implementation by the respective authors.

See Also