Click or drag to resize
NonrecursiveDFS Class

The NonrecursiveDFS class represents a data type for finding the vertices connected to a source vertex S in the undirected graph.

This implementation uses a nonrecursive version of depth-first search with an explicit stack and the path tracing feature found in DepthFirstPaths. 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 graph) proportional to V.

Inheritance Hierarchy
SystemObject
  Algs4NetNonrecursiveDFS

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

The NonrecursiveDFS type exposes the following members.

Constructors
  NameDescription
Public methodNonrecursiveDFS
Computes the vertices connected to the source vertex s in the graph G.
Top
Methods
  NameDescription
Public methodHasPathTo
Is there a path between the source vertex s and vertex v?
Public methodStatic memberMainTest
Demo test the NonrecursiveDFS data type.
Public methodMarked
Is vertex v connected to the source vertex s?
Public methodPathTo
Returns a path between the source vertex s and vertex v, or null if no such path.
Top
Remarks

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

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

See Also