Follow one path as deep as it goes, and only back up when every neighbour is already discovered. The call stack (or an explicit stack) remembers the way back.
Follow one path as deep as it goes, and only back up when every neighbour is already discovered. The call stack (or an explicit stack) remembers the way back.