BFS Approach

BFS then visits vertices that are at a distance of k = 2 from S: