'''simple docstring'''






class    a :



  """simple docstring"""







  def __init__(							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Tuple		= 0
    __UpperCAmelCase:					Tuple		= 0
    __UpperCAmelCase:					Any		= {}







  def    lowercase_  (							self   ,    snake_case_					):

    '''simple docstring'''







    if vertex not in self.adjacency:
      __UpperCAmelCase:					List[str]		= {}
      self.num_vertices += 1







  def    lowercase_  (							self   ,    snake_case_   ,    snake_case_   ,    snake_case_					):

    '''simple docstring'''







    self.add_vertex(snake_case_					)
    self.add_vertex(snake_case_					)

    if head == tail:
      return

    __UpperCAmelCase:					Dict		= weight
    __UpperCAmelCase:					Dict		= weight







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Union[str, Any]		= self.get_edges()
    for edge in edges:
      __UpperCAmelCase:					Any		= edge
      edges.remove((tail, head, weight)					)
    for i in range(len(snake_case_					)					):
      __UpperCAmelCase:					Optional[Any]		= list(edges[i]					)

    edges.sort(key=lambda snake_case_					: e[2]					)
    for i in range(len(snake_case_					) - 1					):
      if edges[i][2] >= edges[i + 1][2]:
        __UpperCAmelCase:					Any		= edges[i][2] + 1
    for edge in edges:
      __UpperCAmelCase:					int		= edge
      __UpperCAmelCase:					int		= weight
      __UpperCAmelCase:					List[Any]		= weight







  def __str__(							self					):

    '''simple docstring'''







    __UpperCAmelCase:					List[Any]		= ""
    for tail in self.adjacency:
      for head in self.adjacency[tail]:
        __UpperCAmelCase:					str		= self.adjacency[head][tail]
        string += F'''{head} -> {tail} == {weight}\n'''
    return string.rstrip("""\n"""					)







  def    lowercase_  (							self					):

    '''simple docstring'''







    __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    lowercase_  (							self					):

    '''simple docstring'''







    return self.adjacency.keys()







  @staticmethod
  def    lowercase_  (							snake_case_=None   ,    snake_case_=None					):

    '''simple docstring'''







    __UpperCAmelCase:					Union[str, Any]		= Graph()
    if vertices is None:
      __UpperCAmelCase:					Union[str, Any]		= []
    if edges is None:
      __UpperCAmelCase:					Dict		= []
    for vertex in vertices:
      g.add_vertex(snake_case_					)
    for edge in edges:
      g.add_edge(*snake_case_					)
    return g




  class    a :



    """simple docstring"""







    def __init__(							self					):

      '''simple docstring'''







      __UpperCAmelCase:					str		= {}
      __UpperCAmelCase:					List[Any]		= {}







    def __len__(							self					):

      '''simple docstring'''







      return len(self.parent					)







    def    lowercase_  (							self   ,    snake_case_					):

      '''simple docstring'''







      if item in self.parent:
        return self.find(snake_case_					)

      __UpperCAmelCase:					Union[str, Any]		= item
      __UpperCAmelCase:					List[Any]		= 0
      return item







    def    lowercase_  (							self   ,    snake_case_					):

      '''simple docstring'''







      if item not in self.parent:
        return self.make_set(snake_case_					)
      if item != self.parent[item]:
        __UpperCAmelCase:					Any		= self.find(self.parent[item]					)
      return self.parent[item]







    def    lowercase_  (							self   ,    snake_case_   ,    snake_case_					):

      '''simple docstring'''







      __UpperCAmelCase:					Optional[int]		= self.find(snake_case_					)
      __UpperCAmelCase:					Optional[Any]		= self.find(snake_case_					)

      if roota == roota:
        return roota

      if self.rank[roota] > self.rank[roota]:
        __UpperCAmelCase:					List[Any]		= roota
        return roota

      if self.rank[roota] < self.rank[roota]:
        __UpperCAmelCase:					Union[str, Any]		= roota
        return roota

      if self.rank[roota] == self.rank[roota]:
        self.rank[roota] += 1
        __UpperCAmelCase:					Optional[int]		= roota
        return roota
      return None







  @staticmethod
  def    lowercase_  (							snake_case_					):

    '''simple docstring'''







    __UpperCAmelCase:					Optional[int]		= graph.num_vertices

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

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

          if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
            __UpperCAmelCase:					Optional[int]		= [head, tail, weight]
      for vertex in cheap_edge:
        if cheap_edge[vertex] != -1:
          __UpperCAmelCase:					int		= cheap_edge[vertex]
          if union_find.find(snake_case_					) != union_find.find(snake_case_					):
            union_find.union(snake_case_   ,    snake_case_					)
            mst_edges.append(cheap_edge[vertex]					)
            __UpperCAmelCase:					str		= num_components - 1
    __UpperCAmelCase:					str		= Graph.build(edges=snake_case_					)
    return mst


'''simple docstring'''






from __future__ import annotations

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

# initial triangle of Koch snowflake
SCREAMING_SNAKE_CASE_	   =			numpy.array([0, 0])
SCREAMING_SNAKE_CASE_	   =			numpy.array([0.5, 0.866_0254])
SCREAMING_SNAKE_CASE_	   =			numpy.array([1, 0])
SCREAMING_SNAKE_CASE_	   =			[VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1]






def  UpperCamelCase__					(					_lowercase    :				list[numpy.ndarray]   ,    _lowercase    :				int     )							->	list[numpy.ndarray]:
  __UpperCAmelCase:					int		= initial_vectors
  for _ in range(_lowercase     ):
    __UpperCAmelCase:					Any		= iteration_step(_lowercase     )
  return vectors






def  UpperCamelCase__					(					_lowercase    :				list[numpy.ndarray]     )							->	list[numpy.ndarray]:
  __UpperCAmelCase:					Optional[int]		= []
  for i, start_vector in enumerate(vectors[:-1]     ):
    __UpperCAmelCase:					Union[str, Any]		= vectors[i + 1]
    new_vectors.append(_lowercase     )
    __UpperCAmelCase:					Optional[int]		= end_vector - start_vector
    new_vectors.append(start_vector + difference_vector / 3     )
    new_vectors.append(
        start_vector + difference_vector / 3 + rotate(difference_vector / 3   ,    6_0     )     )
    new_vectors.append(start_vector + difference_vector * 2 / 3     )
  new_vectors.append(vectors[-1]     )
  return new_vectors






def  UpperCamelCase__					(					_lowercase    :				numpy.ndarray   ,    _lowercase    :				float     )							->	numpy.ndarray:
  __UpperCAmelCase:					Tuple		= numpy.radians(_lowercase     )
  __UpperCAmelCase, __UpperCAmelCase:					Optional[Any]		= numpy.cos(_lowercase     ), numpy.sin(_lowercase     )
  __UpperCAmelCase:					Tuple		= numpy.array(((c, -s), (s, c))     )
  return numpy.dot(_lowercase   ,    _lowercase     )






def  UpperCamelCase__					(					_lowercase    :				list[numpy.ndarray]     )							->	None:
  __UpperCAmelCase:					Union[str, 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:					Dict		= zip(*_lowercase     )
  plt.plot(_lowercase   ,    _lowercase     )
  plt.show()


if __name__ == "__main__":
    import doctest

    doctest.testmod()

    SCREAMING_SNAKE_CASE_	   =			iterate(INITIAL_VECTORS, 5)
    plot(processed_vectors)