Roku data pipelines can depend on one another, and a circular dependency prevents the pipeline schedule from completing. Given a directed dependency graph, determine whether it contains at least one cycle.
Use depth-first search with three states for each node: unvisited, currently visiting, and fully processed.
Implement detect_cycle(graph), where graph is a dictionary mapping each pipeline name to a list of pipeline names that must run after it. A referenced pipeline may appear only in an adjacency list and does not need its own dictionary entry. Return True if the directed graph contains a cycle; otherwise, return False.
def detect_cycle(graph):