BFS Approach

This policy guarantees that the blue vertex will be visited at a distance of k = 4 from S: