Change in traversal function to correctly calculate distance of source from source as 0