public boolean hasCycle(){
        Hashtable<Vertex,Color> color=new Hashtable<Vertex,Color>();
        LinkedList<Vertex> vertices=graph.getVertices();
        Iterator<Vertex> i = new Iterator<Vertex>(vertices);
        while(i.hasNext()){
            Vertex v = i.getNext();
            color.put(v, Color.WHITE);
        }
        i.clear();
        while(i.hasNext()){
            Vertex v = i.getNext();
            if(color.get(v)==Color.WHITE){
                if(DFSCycle(v,color)==true){
                    return true;
                }
            }
        }
        return false;
    }