Package dsa
Class DiCycle
java.lang.Object
dsa.DiCycle
An immutable data type to determine whether a digraph has a directed cycle and, if so, find such a cycle.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
DiCycle
Determines whether the digraphG
has a directed cycle and, if so, finds such a cycle.- Parameters:
G
- the digraph.
-
-
Method Details
-
hasCycle
public boolean hasCycle()Returnstrue
if a directed cycle was detected, andfalse
otherwise.- Returns:
true
if a directed cycle was detected, andfalse
otherwise.
-
cycle
Returns a directed cycle, ornull
.- Returns:
- a directed cycle, or
null
.
-
main
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-