






"""simple docstring"""





from __future__ import annotations

from typing import Any






class 	a		:






    def __init__(			self	:				List[str]			,		__SCREAMING_SNAKE_CASE	:				int   )	->						None:
      lowerCamelCase_       	=		num_of_nodes
      lowerCamelCase_       	=		[]
      lowerCamelCase_       	=		{}






    def   UpperCamelCase			(			self	:				Tuple			,		__SCREAMING_SNAKE_CASE	:				int			,		__SCREAMING_SNAKE_CASE	:				int			,		__SCREAMING_SNAKE_CASE	:				int   )	->						None:
      self.m_edges.append([u_node, v_node, weight]   )






    def   UpperCamelCase			(			self	:				Any			,		__SCREAMING_SNAKE_CASE	:				int   )	->						int:

      if self.m_component[u_node] == u_node:
        return u_node
      return self.find_component(self.m_component[u_node]   )






    def   UpperCamelCase			(			self	:				int			,		__SCREAMING_SNAKE_CASE	:				int   )	->						None:

      if self.m_component[u_node] != u_node:
        for k in self.m_component:
          lowerCamelCase_       	=		self.find_component(__SCREAMING_SNAKE_CASE   )






    def   UpperCamelCase			(			self	:				List[Any]			,		__SCREAMING_SNAKE_CASE	:				list[int]			,		__SCREAMING_SNAKE_CASE	:				int			,		__SCREAMING_SNAKE_CASE	:				int   )	->						None:

      if component_size[u_node] <= component_size[v_node]:
        lowerCamelCase_       	=		v_node
        component_size[v_node] += component_size[u_node]
        self.set_component(__SCREAMING_SNAKE_CASE   )

      elif component_size[u_node] >= component_size[v_node]:
        lowerCamelCase_       	=		self.find_component(__SCREAMING_SNAKE_CASE   )
        component_size[u_node] += component_size[v_node]
        self.set_component(__SCREAMING_SNAKE_CASE   )






    def   UpperCamelCase			(			self	:				Optional[Any]   )	->						None:
      lowerCamelCase_       	=		[]
      lowerCamelCase_       	=		0

      lowerCamelCase_       	=		[-1] * self.m_num_of_nodes

      # A list of components (initialized to all of the nodes)
      for node in range(self.m_num_of_nodes   ):
        self.m_component.update({node: node}   )
        component_size.append(1   )

      lowerCamelCase_       	=		self.m_num_of_nodes

      while num_of_components > 1:
        for edge in self.m_edges:
          lowerCamelCase_	,      lowerCamelCase_	,      lowerCamelCase_       	=		edge

          lowerCamelCase_       	=		self.m_component[u]
          lowerCamelCase_       	=		self.m_component[v]

          if u_component != v_component:

            for component in (u_component, v_component):
              if (
                  minimum_weight_edge[component] == -1
                  or minimum_weight_edge[component][2] > w
              ):
                lowerCamelCase_       	=		[u, v, w]

        for edge in minimum_weight_edge:
          if isinstance(__SCREAMING_SNAKE_CASE			,		__SCREAMING_SNAKE_CASE   ):
            lowerCamelCase_	,      lowerCamelCase_	,      lowerCamelCase_       	=		edge

            lowerCamelCase_       	=		self.m_component[u]
            lowerCamelCase_       	=		self.m_component[v]

            if u_component != v_component:
              mst_weight += w
              self.union(__SCREAMING_SNAKE_CASE			,		__SCREAMING_SNAKE_CASE			,		__SCREAMING_SNAKE_CASE   )
              print(F'''Added edge [{u} - {v}]\nAdded weight: {w}\n'''   )
              num_of_components -= 1

        lowerCamelCase_       	=		[-1] * self.m_num_of_nodes
      print(F'''The total weight of the minimal spanning tree is: {mst_weight}'''   )







def 	lowerCamelCase__			(				) ->							None:
  pass


if __name__ == "__main__":
  import doctest

  doctest.testmod()












"""simple docstring"""





def 	lowerCamelCase__			(				_lowerCamelCase			:						str					) ->							bool:
  lowerCamelCase_       	=		0
  for ch in input_str:
    lowerCamelCase_       	=		ord(_lowerCamelCase					)
    lowerCamelCase_       	=		pow(2						,							_lowerCamelCase					)

    # If we already turned on bit for current character's unicode
    if bitmap >> ch_unicode & 1 == 1:
      return False
    bitmap |= ch_bit_index_on
  return True


if __name__ == "__main__":
  import doctest

  doctest.testmod()




