Compute average values for all vertices using weights of shortest paths store in dp .
for i in range ( V ) : NEW_LINE INDENT if ( dp [ V ] [ i ] != - 1 ) : NEW_LINE INDENT for j in range ( V ) : NEW_LINE INDENT if ( dp [ j ] [ i ] != - 1 ) : NEW_LINE INDENT avg [ i ] = max ( avg [ i ] , ( dp [ V ] [ i ] - dp [ j ] [ i ] ) / ( V - j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT