Graph/cycle_detection library
♻️ Cycle Detection
Provides two utilities:
-
hasCycleDirected: Detects cycles in a directed graph using DFS with recursion stack (colors/visiting set).
-
hasCycleUndirected: Detects cycles in an undirected graph using DFS tracking parent pointers.
-
Time complexity: O(V + E)
-
Space complexity: O(V)
Functions
-
hasCycleDirected<
T> (Map< T, List< graph) → boolT> > -
hasCycleUndirected<
T> (Map< T, List< graph) → boolT> >