Storing distance from end1 to node u
dist1 [ u ] = 1 + dist1 [ p ] NEW_LINE for i in range ( len ( adj [ u ] ) ) : NEW_LINE INDENT if ( adj [ u ] [ i ] != p ) : NEW_LINE INDENT findDistancefromFirst ( adj [ u ] [ i ] , u ) NEW_LINE DEDENT DEDENT