filling up the dp table
for i in range ( 1 , V + 1 ) : NEW_LINE INDENT for j in range ( V ) : NEW_LINE INDENT for k in range ( len ( edges [ j ] ) ) : NEW_LINE INDENT if ( dp [ i - 1 ] [ edges [ j ] [ k ] . From ] != - 1 ) : NEW_LINE INDENT curr_wt = ( dp [ i - 1 ] [ edges [ j ] [ k ] . From ] + edges [ j ] [ k ] . weight ) NEW_LINE if ( dp [ i ] [ j ] == - 1 ) : NEW_LINE INDENT dp [ i ] [ j ] = curr_wt NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = min ( dp [ i ] [ j ] , curr_wt ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT