Juspay Hyper can model payment-processing steps as directed dependencies, where an edge from step A to step B means A must complete before B starts. Given this dependency graph, determine whether it contains a directed cycle.
Implement has_cycle(graph). Return True if any directed cycle exists, otherwise return False.
graph, a dictionary mapping each node name, represented by a string, to a list of neighboring node names.True when the graph contains at least one directed cycle; otherwise return False.def has_cycle(graph):