Check for all intermediate vertex
for k in range ( V ) : NEW_LINE INDENT for i in range ( V ) : NEW_LINE INDENT for j in range ( V ) : NEW_LINE INDENT mat [ i ] [ j ] = ( mat [ i ] [ j ] or mat [ i ] [ k ] and mat [ k ] [ j ] ) NEW_LINE DEDENT DEDENT DEDENT