






'''simple docstring'''

from __future__ import annotations

from typing import Any




class      A     :






 """simple docstring"""





 def __init__(				self      ,  __lowerCAmelCase			):
       UpperCamelCase_					: List[Any]            =				num_of_nodes
       UpperCamelCase_					: list[list[int]]            =				[]
       UpperCamelCase_					: dict[int, int]            =				{}
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase      ,  __lowerCAmelCase      ,  __lowerCAmelCase			):
       self.m_edges.append([u_node, v_node, weight]			)
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase			):

       if self.m_component[u_node] == u_node:
             return u_node
       return self.find_component(self.m_component[u_node]			)
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase			):

       if self.m_component[u_node] != u_node:
             for k in self.m_component:
                   UpperCamelCase_					: Tuple            =				self.find_component(__lowerCAmelCase			)
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase      ,  __lowerCAmelCase      ,  __lowerCAmelCase			):

       if component_size[u_node] <= component_size[v_node]:
             UpperCamelCase_					: Optional[int]            =				v_node
             component_size[v_node] += component_size[u_node]
             self.set_component(__lowerCAmelCase			)

       elif component_size[u_node] >= component_size[v_node]:
             UpperCamelCase_					: Any            =				self.find_component(__lowerCAmelCase			)
             component_size[u_node] += component_size[v_node]
             self.set_component(__lowerCAmelCase			)





 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: int            =				[]
       UpperCamelCase_					: Dict            =				0

       UpperCamelCase_					: list[Any]            =				[-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			)

       UpperCamelCase_					: Union[str, Any]            =				self.m_num_of_nodes

       while num_of_components > 1:
             for edge in self.m_edges:
                   UpperCamelCase_     ,      UpperCamelCase_     ,      UpperCamelCase_					: List[str]            =				edge

                   UpperCamelCase_					: List[str]            =				self.m_component[u]
                   UpperCamelCase_					: Tuple            =				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
                               ):
                                     UpperCamelCase_					: Dict            =				[u, v, w]

             for edge in minimum_weight_edge:
                   if isinstance(__lowerCAmelCase      ,  __lowerCAmelCase			):
                         UpperCamelCase_     ,      UpperCamelCase_     ,      UpperCamelCase_					: Any            =				edge

                         UpperCamelCase_					: List[Any]            =				self.m_component[u]
                         UpperCamelCase_					: int            =				self.m_component[v]

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

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






def 				snake_case       (  )							->					None:





      """simple docstring"""



if __name__ == "__main__":
      import doctest

      doctest.testmod()














'''simple docstring'''

from __future__ import annotations

from collections import namedtuple



def 				snake_case       (  a_				:			float     , a_				:			float     , a_				:			float						)							->					tuple:





      """simple docstring"""

      UpperCamelCase_					: Tuple            =				namedtuple("""result"""     , """name value"""						)
      if (voltage, current, power).count(0						) != 1:
            raise ValueError("""Only one argument must be 0"""						)
      elif power < 0:
            raise ValueError(
                """Power cannot be negative in any electrical/electronics system"""						)
      elif voltage == 0:
            return result("""voltage"""     , power / current						)
      elif current == 0:
            return result("""current"""     , power / voltage						)
      elif power == 0:
            return result("""power"""     , float(round(abs(voltage * current						)     , 2						)						)						)
      else:
            raise ValueError("""Exactly one argument must be 0"""						)


if __name__ == "__main__":
      import doctest

      doctest.testmod()






