state space bfs functional