For this problem i am using bfs , but the bfs tree grows using the invertd edges , therefore , when the nth vetex is found , it will be at the shortest distance from the 1st vertex . To get the min count i am keeping the track of the parents. Help is appreciated!! Here is my implementation: link text