Added BFS distance finding.