Solve a problem involving trees or graphs.
Implement directed-cycle detection for a graph represented as an adjacency list. Return True if any directed cycle exists, otherwise return False.
Use has_cycle(graph), where graph[i] contains the integer vertices reachable from vertex i; vertices are numbered from 0 to len(graph) - 1.
def has_cycle(graph):