'Detect cycle in a Directed graph using BFS algo

I tried looking around the internet, I'm little stuck. Can anyone share the code for how to detect cycle in directed graph using bfs?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source