Returns true if edge u - v is a valid edge to be include in MST . An edge is valid if one end is already included in MST and other is not in MST .
def isValidEdge ( u , v , inMST ) : NEW_LINE INDENT if u == v : NEW_LINE INDENT return False NEW_LINE DEDENT if inMST [ u ] == False and inMST [ v ] == False : NEW_LINE INDENT return False NEW_LINE DEDENT elif inMST [ u ] == True and inMST [ v ] == True : NEW_LINE INDENT return False NEW_LINE DEDENT return True NEW_LINE DEDENT def primMST ( cost ) : NEW_LINE INDENT inMST = [ False ] * V NEW_LINE DEDENT