Lets start with the most obvious problem I can see, that you haven't initialized the bool array visited
bool *visited = new bool[V];
are you sure you didn't mean to initialize it like so?
bool *visited = new bool[V]();
Alternatively just memset etc the array to initialize it.