Cycle detection algorithms for directed and undirected graphs.
Summary
Functions
Determines if a graph is acyclic (contains no cycles).
Determines if a graph contains any cycles.
Functions
Determines if a graph is acyclic (contains no cycles).
Time Complexity: O(V + E)
Determines if a graph contains any cycles.
For directed graphs, uses Kahn's algorithm (topological sort). For undirected graphs, uses DFS-based back-edge detection.
Time Complexity: O(V + E)