We consider the graph where node are rooms and you have edges of two types: neighborhood and light switch. We can run a DFS on this graph but we only explore a room once we enter a node that is both lit and neighbors (and not already processed, just like a DFS).