



'''simple docstring'''






from __future__ import annotations

from typing import Any

class 				SCREAMING_SNAKE_CASE:







	"""simple docstring"""






	def __init__(						self			:     Tuple		,			__snake_case			:     int		)			->		None:
								UpperCAmelCase :       str 							=		num_of_nodes
								UpperCAmelCase :       list[list[int]] 							=		[]
								UpperCAmelCase :       dict[int, int] 							=		{}







	def      A	(						self			:     List[str]		,			__snake_case			:     int		,			__snake_case			:     int		,			__snake_case			:     int		)			->		None:
								self.m_edges.append([u_node, v_node, weight]		)







	def      A	(						self			:     Union[str, Any]		,			__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      A	(						self			:     Any		,			__snake_case			:     int		)			->		None:

								if self.m_component[u_node] != u_node:
															for k in self.m_component:
																						UpperCAmelCase :       int 							=		self.find_component(__snake_case		)







	def      A	(						self			:     Dict		,			__snake_case			:     list[int]		,			__snake_case			:     int		,			__snake_case			:     int		)			->		None:

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

								elif component_size[u_node] >= component_size[v_node]:
															UpperCAmelCase :       Optional[Any] 							=		self.find_component(__snake_case		)
															component_size[u_node] += component_size[v_node]
															self.set_component(__snake_case		)







	def      A	(						self			:     Optional[int]		)			->		None:
								UpperCAmelCase :       str 							=		[]
								UpperCAmelCase :       Any 							=		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 :       Any 							=		edge

																						UpperCAmelCase :       List[Any] 							=		self.m_component[u]
																						UpperCAmelCase :       Any 							=		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 :       Union[str, Any] 							=		[u, v, w]

															for edge in minimum_weight_edge:
																						if isinstance(__snake_case		,			__snake_case		):
																													UpperCAmelCase							,		UpperCAmelCase							,		UpperCAmelCase :       int 							=		edge

																													UpperCAmelCase :       int 							=		self.m_component[u]
																													UpperCAmelCase :       Optional[int] 							=		self.m_component[v]

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

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


def  snake_case_     (					)      ->   None:
							pass


if __name__ == "__main__":
						import doctest

						doctest.testmod()










'''simple docstring'''






from __future__ import annotations

import matplotlib.pyplot as plt  # type: ignore
import numpy

# initial triangle of Koch snowflake
UpperCamelCase__:   Tuple								=			numpy.array([0, 0])
UpperCamelCase__:   Union[str, Any]								=			numpy.array([0.5, 0.8660254])
UpperCamelCase__:   Dict								=			numpy.array([1, 0])
UpperCamelCase__:   int								=			[VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1]


def  snake_case_     (					_lowerCAmelCase  :						list[numpy.ndarray]   ,      _lowerCAmelCase  :						int  )      ->   list[numpy.ndarray]:
							UpperCAmelCase :       Union[str, Any] 							=		initial_vectors
							for _ in range(_lowerCAmelCase  ):
														UpperCAmelCase :       Union[str, Any] 							=		iteration_step(_lowerCAmelCase  )
							return vectors


def  snake_case_     (					_lowerCAmelCase  :						list[numpy.ndarray]  )      ->   list[numpy.ndarray]:
							UpperCAmelCase :       Tuple 							=		[]
							for i, start_vector in enumerate(vectors[:-1]  ):
														UpperCAmelCase :       List[str] 							=		vectors[i + 1]
														new_vectors.append(_lowerCAmelCase  )
														UpperCAmelCase :       Optional[Any] 							=		end_vector - start_vector
														new_vectors.append(start_vector + difference_vector / 3  )
														new_vectors.append(
														    start_vector + difference_vector / 3 + rotate(difference_vector / 3   ,      60  )  )
														new_vectors.append(start_vector + difference_vector * 2 / 3  )
							new_vectors.append(vectors[-1]  )
							return new_vectors


def  snake_case_     (					_lowerCAmelCase  :						numpy.ndarray   ,      _lowerCAmelCase  :						float  )      ->   numpy.ndarray:
							UpperCAmelCase :       List[str] 							=		numpy.radians(_lowerCAmelCase  )
							UpperCAmelCase							,		UpperCAmelCase :       Tuple 							=		numpy.cos(_lowerCAmelCase  ), numpy.sin(_lowerCAmelCase  )
							UpperCAmelCase :       Union[str, Any] 							=		numpy.array(((c, -s), (s, c))  )
							return numpy.dot(_lowerCAmelCase   ,      _lowerCAmelCase  )


def  snake_case_     (					_lowerCAmelCase  :						list[numpy.ndarray]  )      ->   None:
							UpperCAmelCase :       List[Any] 							=		plt.gca()
							axes.set_aspect('''equal'''  )

							# matplotlib.pyplot.plot takes a list of all x-coordinates and a list of all
							# y-coordinates as inputs, which are constructed from the vector-list using
							# zip()
							UpperCAmelCase							,		UpperCAmelCase :       str 							=		zip(*_lowerCAmelCase  )
							plt.plot(_lowerCAmelCase   ,      _lowerCAmelCase  )
							plt.show()


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						UpperCamelCase__:   List[Any]								=			iterate(INITIAL_VECTORS, 5)
						plot(processed_vectors)





