EdgeWeightedDirectedCycle Class |
The EdgeWeightedDirectedCycle class represents a data type for determining whether an edge-weighted digraph has a directed cycle. The HasCycle operation determines whether the edge-weighted digraph has a directed cycle and, if so, the Cycle operation returns one.
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. Afterwards, the HasCycle operation takes constant time; the Cycle operation takes time proportional to the length of the cycle.
See to compute a topological order if the edge-weighted digraph is acyclic.
Namespace: Algs4Net
public class EdgeWeightedDirectedCycle
The EdgeWeightedDirectedCycle type exposes the following members.
Name | Description | |
---|---|---|
![]() | EdgeWeightedDirectedCycle |
Determines whether the edge-weighted digraph G has a directed cycle and,
if so, finds such a cycle. |
Name | Description | |
---|---|---|
![]() | GetCycle |
Returns a directed cycle if the edge-weighted digraph has a directed cycle,
and null otherwise. |
![]() ![]() | MainTest |
Demo test the EdgeWeightedDirectedCycle data type. |
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 EdgeWeightedDirectedCycle implementation by the respective authors.