function to find the second minimum edge cost having an end at the vertex i
def secondMin ( adj , i ) : NEW_LINE INDENT first , second = maxsize , maxsize NEW_LINE for j in range ( N ) : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT if adj [ i ] [ j ] <= first : NEW_LINE INDENT second = first NEW_LINE first = adj [ i ] [ j ] NEW_LINE DEDENT elif ( adj [ i ] [ j ] <= second and adj [ i ] [ j ] != first ) : NEW_LINE INDENT second = adj [ i ] [ j ] NEW_LINE DEDENT DEDENT return second NEW_LINE DEDENT