private boolean isCycleHelper(int u, int v, int n, int w){
        if(n == 1){
            int[] adjacent = new int[10];
            adjacent = adjacent(u,w);
            //System.out.println(Arrays.toString(adjacent));
            for(int i = 0; i < adjacent.length; ++i){
                if(v == adjacent[i])
                    return true;
            }
            return false;
        }
        //System.out.println(u+" "+v);
        int[] temp = new int[10];
        temp = this.adjacent(u,w);
        if(temp.length == 6){
            return false;
        }
        for (int i = 0; i < temp.length; i++)
        {
            if (isCycleHelper(temp[i], v, n - 1, w))
                return true;
        }
        return false;
    }