Cycle detection in directed graph issue

how to find cycle in directed graph using bfs? please explain the logic

algo:
compute the indegree for each vertex
push all the nodes with zero indegree in a queue
keep a count variable
while(!q.empty())
take the front of the queue nd iterate over it’s neighbors and decrease their indegree, if indegree becomes zero push in queue
at the end of each iter increase the count

at the end of while loop
check
if(count != no of nodes) it contains a cycle
This is also known as Kahn’s algo