Click or drag to resize
DepthFirstSearch Class

The DepthFirstSearch class represents a data type for determining the vertices connected to a given source vertex S in an undirected graph. For versions that find the paths, see and . This implementation uses depth-first search.

The constructor takes time proportional to V + E (in the worst case), 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
  Algs4NetDepthFirstSearch

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

The DepthFirstSearch type exposes the following members.

Constructors
  NameDescription
Public methodDepthFirstSearch
Computes the vertices in graph G that are connected to the source vertex s.
Top
Properties
  NameDescription
Public propertyCount
Returns the number of vertices connected to the source vertex s.
Top
Methods
  NameDescription
Public methodStatic memberMainTest
Demo test the DepthFirstSearch data type.
Public methodMarked
Is there a path between the source vertex s and vertex v?
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 DepthFirstSearch implementation by the respective authors.

See Also