In Problem 16.4 's solution, we assume a connected undirected graph. So, every node is reachable from any node. The test is to see if there is at least one cycle. I am not clear on how it is possible to encounter a ‘black’ node in the neighbors list, without having seen that cycle before in the check for ‘grey’ node. Are we to check for ‘grey’ instead? Even that is taken care of by the exit criteria of the recursion, no?
I feel this if is not needed:
if(next != pre && next->color != GraphVertex::black)
Please correct me, if I am not seeing the light!