


'''simple docstring'''






from __future__ import annotations

from typing import Any




class  a     :
 def __init__( self      ,				__magic_name__						)					->							None:
      _a			      =							num_of_nodes
      _a			      =							[]
      _a			      =							{}
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							None:
      self.m_edges.append([u_node, v_node, weight]						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__						)					->							int:

      if self.m_component[u_node] == u_node:
           return u_node
      return self.find_component(self.m_component[u_node]						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__						)					->							None:

      if self.m_component[u_node] != u_node:
           for k in self.m_component:
                _a			      =							self.find_component(__magic_name__						)
 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				__magic_name__						)					->							None:

      if component_size[u_node] <= component_size[v_node]:
           _a			      =							v_node
           component_size[v_node] += component_size[u_node]
           self.set_component(__magic_name__						)

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




 def 							__UpperCAmelCase		( self						)					->							None:
      _a			      =							[]
      _a			      =							0

      _a			      =							[-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						)

      _a			      =							self.m_num_of_nodes

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

                _a			      =							self.m_component[u]
                _a			      =							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
                          ):
                               _a			      =							[u, v, w]

           for edge in minimum_weight_edge:
                if isinstance(__magic_name__      ,				__magic_name__						):
                     _a      ,   _a      ,   _a			      =							edge

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

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

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






def 	_A				()   ->  None:




     '''simple docstring'''





if __name__ == "__main__":
 import doctest

 doctest.testmod()





'''simple docstring'''






from typing import Any






def 	_A				(lowerCAmelCase__  :list		)   ->  list[Any]:




     '''simple docstring'''



     if not input_list:
          return []
     _a			      =							[input_list.count(lowerCAmelCase__		) for value in input_list]
     _a			      =							max(lowerCAmelCase__		)  # Gets the maximum count in the input list.
     # Gets values of modes
     return sorted({input_list[i] for i, value in enumerate(lowerCAmelCase__		) if value == y}		)


if __name__ == "__main__":
 import doctest

 doctest.testmod()

