Create Cyclic Binary Tree

This code written by me, checks weather a directed graph has a cycle in it or not.
Sample Input:
2
6 7
0 1
0 4
1 2
1 4
2 3
3 4
3 5
4 2
0 1
0 2
2 3