"""simple docstring"""





from __future__ import annotations

from typing import Any


class   UpperCAmelCase_			:


      def __init__(     self	,    a							) ->      None:
             lowercase__    :	Optional[Any]     					=			num_of_nodes
             lowercase__    :	list[list[int]]     					=			[]
             lowercase__    :	dict[int, int]     					=			{}


      def 	_UpperCAmelCase (     self	,    a	,    a	,    a							) ->      None:
             self.m_edges.append([u_node, v_node, weight]							)


      def 	_UpperCAmelCase (     self	,    a							) ->      int:

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


      def 	_UpperCAmelCase (     self	,    a							) ->      None:

             if self.m_component[u_node] != u_node:
                    for k in self.m_component:
                           lowercase__    :	Optional[int]     					=			self.find_component(a							)


      def 	_UpperCAmelCase (     self	,    a	,    a	,    a							) ->      None:

             if component_size[u_node] <= component_size[v_node]:
                    lowercase__    :	Any     					=			v_node
                    component_size[v_node] += component_size[u_node]
                    self.set_component(a							)

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


      def 	_UpperCAmelCase (     self							) ->      None:
             lowercase__    :	Optional[Any]     					=			[]
             lowercase__    :	Tuple     					=			0

             lowercase__    :	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							)

             lowercase__    :	Optional[int]     					=			self.m_num_of_nodes

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

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

                    for edge in minimum_weight_edge:
                           if isinstance(a	,    a							):
                                  lowercase__					,   lowercase__					,   lowercase__    :	List[Any]     					=			edge

                                  lowercase__    :	Dict     					=			self.m_component[u]
                                  lowercase__    :	Optional[Any]     					=			self.m_component[v]

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

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





def        a_  (   ):





       '''simple docstring'''



if __name__ == "__main__":
       import doctest

       doctest.testmod()


"""simple docstring"""





from collections.abc import Sequence





def        a_  (   _lowerCAmelCase						:				Sequence[float]     ,				_lowerCAmelCase						:				float  ):





       '''simple docstring'''

       return sum(c * (x**i) for i, c in enumerate(_lowerCAmelCase  )  )





def        a_  (   _lowerCAmelCase						:				Sequence[float]     ,				_lowerCAmelCase						:				float  ):





       '''simple docstring'''

       lowercase__    :	int     					=			0.0
       for coeff in reversed(_lowerCAmelCase  ):
              lowercase__    :	List[Any]     					=			result * x + coeff
       return result


if __name__ == "__main__":
       _UpperCamelCase     :		int											=					(0.0, 0.0, 5.0, 9.3, 7.0)
       _UpperCamelCase     :		Dict											=					1_0.0
       print(evaluate_poly(poly, x))
       print(horner(poly, x))

