Pseudocode for graph chase algorithm
Hint: What's the size of the state space?

The state of the world at any point is determined by _____.  Therefore, there are ____ many possible states.

Fill in the blanks, then think about how to use those facts to help you devise an algorithm.