






class        lowerCAmelCase_				:







				"""simple docstring"""




				def __init__( self     :List[Any]     ):
					UpperCamelCase__ :Any						=      0
					UpperCamelCase__ :str						=      0
					UpperCamelCase__ :Union[str, Any]						=      {}







				def 				__a   ( self     :List[Any]  ,     lowerCamelCase__     :Optional[int]     ):
					if vertex not in self.adjacency:
						UpperCamelCase__ :List[str]						=      {}
						self.num_vertices += 1







				def 				__a   ( self     :Dict  ,     lowerCamelCase__     :Optional[int]  ,     lowerCamelCase__     :Union[str, Any]  ,     lowerCamelCase__     :List[str]     ):
					self.add_vertex(lowerCamelCase__     )
					self.add_vertex(lowerCamelCase__     )

					if head == tail:
						return

					UpperCamelCase__ :List[Any]						=      weight
					UpperCamelCase__ :Optional[int]						=      weight







				def 				__a   ( self     :Optional[int]     ):
					UpperCamelCase__ :Tuple						=      self.get_edges()
					for edge in edges:
						UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__ :Dict						=      edge
						edges.remove((tail, head, weight)     )
					for i in range(len(lowerCamelCase__     )     ):
						UpperCamelCase__ :int						=      list(edges[i]     )

					edges.sort(key=lambda lowerCamelCase__     : e[2]     )
					for i in range(len(lowerCamelCase__     ) - 1     ):
						if edges[i][2] >= edges[i + 1][2]:
							UpperCamelCase__ :Any						=      edges[i][2] + 1
					for edge in edges:
						UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__ :List[str]						=      edge
						UpperCamelCase__ :Union[str, Any]						=      weight
						UpperCamelCase__ :str						=      weight







				def __str__( self     :int     ):
					UpperCamelCase__ :str						=      """"""
					for tail in self.adjacency:
						for head in self.adjacency[tail]:
							UpperCamelCase__ :Optional[int]						=      self.adjacency[head][tail]
							string += f"""{head} -> {tail} == {weight}\n"""
					return string.rstrip("""\n"""     )







				def 				__a   ( self     :Dict     ):
					UpperCamelCase__ :Optional[int]						=      []
					for tail in self.adjacency:
						for head in self.adjacency[tail]:
							output.append((tail, head, self.adjacency[head][tail])     )
					return output







				def 				__a   ( self     :int     ):
					return self.adjacency.keys()







				@staticmethod
				def 				__a   ( lowerCamelCase__     :Dict=None  ,     lowerCamelCase__     :Tuple=None     ):
					UpperCamelCase__ :Optional[int]						=      Graph()
					if vertices is None:
						UpperCamelCase__ :Optional[int]						=      []
					if edges is None:
						UpperCamelCase__ :List[str]						=      []
					for vertex in vertices:
						g.add_vertex(lowerCamelCase__     )
					for edge in edges:
						g.add_edge(*lowerCamelCase__     )
					return g

				class        lowerCAmelCase_				:







								"""simple docstring"""




								def __init__( self     :List[Any]     ):
									UpperCamelCase__ :str						=      {}
									UpperCamelCase__ :Union[str, Any]						=      {}







								def __len__( self     :Union[str, Any]     ):
									return len(self.parent     )







								def 				__a   ( self     :Union[str, Any]  ,     lowerCamelCase__     :Tuple     ):
									if item in self.parent:
										return self.find(lowerCamelCase__     )

									UpperCamelCase__ :Any						=      item
									UpperCamelCase__ :Optional[Any]						=      0
									return item







								def 				__a   ( self     :Optional[int]  ,     lowerCamelCase__     :Any     ):
									if item not in self.parent:
										return self.make_set(lowerCamelCase__     )
									if item != self.parent[item]:
										UpperCamelCase__ :Optional[int]						=      self.find(self.parent[item]     )
									return self.parent[item]







								def 				__a   ( self     :Optional[int]  ,     lowerCamelCase__     :Tuple  ,     lowerCamelCase__     :List[str]     ):
									UpperCamelCase__ :Any						=      self.find(lowerCamelCase__     )
									UpperCamelCase__ :List[str]						=      self.find(lowerCamelCase__     )

									if roota == roota:
										return roota

									if self.rank[roota] > self.rank[roota]:
										UpperCamelCase__ :List[str]						=      roota
										return roota

									if self.rank[roota] < self.rank[roota]:
										UpperCamelCase__ :Dict						=      roota
										return roota

									if self.rank[roota] == self.rank[roota]:
										self.rank[roota] += 1
										UpperCamelCase__ :str						=      roota
										return roota
									return None







				@staticmethod
				def 				__a   ( lowerCamelCase__     :Tuple     ):
					UpperCamelCase__ :Optional[Any]						=      graph.num_vertices

					UpperCamelCase__ :Optional[int]						=      Graph.UnionFind()
					UpperCamelCase__ :Union[str, Any]						=      []
					while num_components > 1:
						UpperCamelCase__ :Union[str, Any]						=      {}
						for vertex in graph.get_vertices():
							UpperCamelCase__ :str						=      -1

						UpperCamelCase__ :str						=      graph.get_edges()
						for edge in edges:
							UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__ :Tuple						=      edge
							edges.remove((tail, head, weight)     )
						for edge in edges:
							UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__ :str						=      edge
							UpperCamelCase__ :Dict						=      union_find.find(lowerCamelCase__     )
							UpperCamelCase__ :Optional[int]						=      union_find.find(lowerCamelCase__     )
							if seta != seta:
								if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
									UpperCamelCase__ :int						=      [head, tail, weight]

								if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
									UpperCamelCase__ :List[str]						=      [head, tail, weight]
						for vertex in cheap_edge:
							if cheap_edge[vertex] != -1:
								UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__ :Union[str, Any]						=      cheap_edge[vertex]
								if union_find.find(lowerCamelCase__     ) != union_find.find(lowerCamelCase__     ):
									union_find.union(lowerCamelCase__  ,     lowerCamelCase__     )
									mst_edges.append(cheap_edge[vertex]     )
									UpperCamelCase__ :List[Any]						=      num_components - 1
					UpperCamelCase__ :List[str]						=      Graph.build(edges=lowerCamelCase__     )
					return mst





from __future__ import annotations





def        __UpperCAmelCase						(							lowerCamelCase_ :     list[float]  )       ->  float:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Tuple					  =      0.0_0
			SCREAMING_SNAKE_CASE_   : Tuple					  =      0
			for resistor in resistors:
						if resistor <= 0:
									SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      F'Resistor at index {index} has a negative or zero value!'
									raise ValueError(lowerCamelCase_  )
						first_sum += 1 / float(lowerCamelCase_  )
						index += 1
			return 1 / first_sum





def        __UpperCAmelCase						(							lowerCamelCase_ :     list[float]  )       ->  float:







			"""simple docstring"""





			SCREAMING_SNAKE_CASE_   : Dict					  =      0.0_0
			SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      0
			for resistor in resistors:
						sum_r += resistor
						if resistor < 0:
									SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      F'Resistor at index {index} has a negative value!'
									raise ValueError(lowerCamelCase_  )
						index += 1
			return sum_r


if __name__ == "__main__":
						import doctest

						doctest.testmod()



