Implement a function to detect a cycle in a directed graph, where the graph represents network connections between routers.
Use an adjacency list, where graph[i] contains the router indices directly reachable from router i. Return True if any directed cycle exists, including a self-loop, and False otherwise.
Function signature: has_cycle(graph). The input is a list of lists of integers, and the output is a Boolean.
def has_cycle(graph):