Edge cases: What if the graph is not connected?
What if the cat starts on the food (vertex )? The problem statement says the cat cannot enter vertex , so this will not happen. What if there are self-loops?
The problem uses an undirected graph without self-loops, but if they existed, they would not change the outcome. Make sure your state representing handles all cases. Use a array or map states to integers carefully.