Given a directed graph with n nodes labeled from 0 to n - 1 and a list of directed edges edges, determine whether the graph contains a cycle. Return True if any cycle exists and False otherwise. The graph may be disconnected.
def has_cycle(n, edges):