Find minimum weight valid edge .
minn = INT_MAX NEW_LINE a = - 1 NEW_LINE b = - 1 NEW_LINE for i in range ( V ) : NEW_LINE INDENT for j in range ( V ) : NEW_LINE INDENT if cost [ i ] [ j ] < minn : NEW_LINE INDENT if isValidEdge ( i , j , inMST ) : NEW_LINE INDENT minn = cost [ i ] [ j ] NEW_LINE a = i NEW_LINE b = j NEW_LINE DEDENT DEDENT DEDENT DEDENT if a != - 1 and b != - 1 : NEW_LINE INDENT print ( " Edge ▁ % d : ▁ ( % d , ▁ % d ) ▁ cost : ▁ % d " % ( edge_count , a , b , minn ) ) NEW_LINE edge_count += 1 NEW_LINE mincost += minn NEW_LINE inMST [ b ] = inMST [ a ] = True NEW_LINE DEDENT print ( " Minimum ▁ cost ▁ = ▁ % d " % mincost ) NEW_LINE