At Cisco, network data flows through various routers, and managing connections efficiently is crucial. Implement a function in Python to detect a cycle in a directed graph, where the graph represents network connections between routers.
Check out your Company Bowl for anonymous work chats.