Will this help? http://www.allprogrammingtutorials.com/tutorials/bfs-shortest-reach-challenge.php for kgisl/algorithms#1