Storing distance from end2 to node u
dist2 [ u ] = 1 + dist2 [ p ] NEW_LINE for i in range ( len ( adj [ u ] ) ) : NEW_LINE INDENT if ( adj [ u ] [ i ] != p ) : NEW_LINE INDENT findDistancefromSecond ( adj [ u ] [ i ] , u ) NEW_LINE DEDENT DEDENT def findNodes ( ) : NEW_LINE global adj , lvl , dist1 , dist2 , end1 , end2 , maxi NEW_LINE n = 5 NEW_LINE