parameters: (self, N, connections)
return_statement: return result if union_find.count == 1 else -1
docstring: :type N: int
          :type connections: List[List[int]]
          :rtype: int
docstring_summary: :type N: int
          :type connections: List[List[int]]
          :rtype: int
docstring_tokens: : type N : int : type connections : List [ List [ int ]] : rtype : int
function: def minimumCost(self, N, connections):
          """
          :type N: int
          :type connections: List[List[int]]
          :rtype: int
          """
          connections.sort(key = lambda x: x[2])
          union_find = UnionFind(N)
          result = 0
          for u, v, val in connections:
              if union_find.union_set(u-1, v-1):
                  result += val
          return result if union_find.count == 1 else -1
function_tokens: def minimumCost ( self , N , connections ) : connections . sort ( key = lambda x : x [ 2 ] ) union_find = UnionFind ( N ) result = 0 for u , v , val in connections : if union_find . union_set ( u - 1 , v - 1 ) : result += val return result if union_find . count == 1 else - 1