




"""simple docstring"""






class lowerCAmelCase__	:






			'''simple docstring'''



			def __init__(  self  ):
							_lowerCamelCase     :			Tuple    =    0
							_lowerCamelCase     :			Any    =    0
							_lowerCamelCase     :			int    =    {}
			def 					A_    (  self  ,      lowercase  ):
							if vertex not in self.adjacency:
											_lowerCamelCase     :			Optional[Any]    =    {}
											self.num_vertices += 1
			def 					A_    (  self  ,      lowercase  ,      lowercase  ,      lowercase  ):
							self.add_vertex(lowercase  )
							self.add_vertex(lowercase  )

							if head == tail:
											return

							_lowerCamelCase     :			Optional[int]    =    weight
							_lowerCamelCase     :			Optional[int]    =    weight
			def 					A_    (  self  ):
							_lowerCamelCase     :			Optional[Any]    =    self.get_edges()
							for edge in edges:
											_lowerCamelCase, _lowerCamelCase, _lowerCamelCase     :			Tuple    =    edge
											edges.remove((tail, head, weight)  )
							for i in range(len(lowercase  )  ):
											_lowerCamelCase     :			Any    =    list(edges[i]  )

							edges.sort(key=lambda lowercase  : e[2]  )
							for i in range(len(lowercase  ) - 1  ):
											if edges[i][2] >= edges[i + 1][2]:
															_lowerCamelCase     :			Dict    =    edges[i][2] + 1
							for edge in edges:
											_lowerCamelCase, _lowerCamelCase, _lowerCamelCase     :			List[str]    =    edge
											_lowerCamelCase     :			int    =    weight
											_lowerCamelCase     :			Dict    =    weight
			def __str__(  self  ):
							_lowerCamelCase     :			Tuple    =    ''
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															_lowerCamelCase     :			Optional[Any]    =    self.adjacency[head][tail]
															string += F'''{head} -> {tail} == {weight}\n'''
							return string.rstrip('\n'  )
			def 					A_    (  self  ):
							_lowerCamelCase     :			List[str]    =    []
							for tail in self.adjacency:
											for head in self.adjacency[tail]:
															output.append((tail, head, self.adjacency[head][tail])  )
							return output
			def 					A_    (  self  ):
							return self.adjacency.keys()
			@staticmethod
			def 					A_    (  lowercase=None  ,      lowercase=None  ):
							_lowerCamelCase     :			List[str]    =    Graph()
							if vertices is None:
											_lowerCamelCase     :			Optional[Any]    =    []
							if edges is None:
											_lowerCamelCase     :			Dict    =    []
							for vertex in vertices:
											g.add_vertex(lowercase  )
							for edge in edges:
											g.add_edge(*lowercase  )
							return g






			class lowerCAmelCase__	:






						'''simple docstring'''



						def __init__(  self  ):
										_lowerCamelCase     :			Dict    =    {}
										_lowerCamelCase     :			List[str]    =    {}
						def __len__(  self  ):
										return len(self.parent  )
						def 					A_    (  self  ,      lowercase  ):
										if item in self.parent:
														return self.find(lowercase  )

										_lowerCamelCase     :			str    =    item
										_lowerCamelCase     :			int    =    0
										return item
						def 					A_    (  self  ,      lowercase  ):
										if item not in self.parent:
														return self.make_set(lowercase  )
										if item != self.parent[item]:
														_lowerCamelCase     :			Tuple    =    self.find(self.parent[item]  )
										return self.parent[item]






						def 					A_    (  self  ,      lowercase  ,      lowercase  ):
										_lowerCamelCase     :			int    =    self.find(lowercase  )
										_lowerCamelCase     :			Union[str, Any]    =    self.find(lowercase  )

										if roota == roota:
														return roota

										if self.rank[roota] > self.rank[roota]:
														_lowerCamelCase     :			int    =    roota
														return roota

										if self.rank[roota] < self.rank[roota]:
														_lowerCamelCase     :			Any    =    roota
														return roota

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

			@staticmethod
			def 					A_    (  lowercase  ):
							_lowerCamelCase     :			str    =    graph.num_vertices

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

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

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



from math import sqrt

import numpy as np
from sympy import symbols

# Coefficient
# Speed of light (m/s)
_snake_case             =     2_99_79_24_58

# Symbols
_snake_case      ,       _snake_case      ,       _snake_case      ,       _snake_case             =     symbols('''ct x y z''')






def 		lowercase_(  SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  if velocity > c:
    raise ValueError("Speed must not exceed light speed 299,792,458 [m/s]!"	)
  elif velocity < 1:
    # Usually the speed should be much higher than 1 (c order of magnitude)
    raise ValueError("Speed must be greater than or equal to 1!"	)

  return velocity / c






def 		lowercase_(  SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  return 1 / sqrt(1 - beta(SCREAMING_SNAKE_CASE_	) ** 2	)






def 		lowercase_(  SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  return np.array(
      [
          [gamma(SCREAMING_SNAKE_CASE_	), -gamma(SCREAMING_SNAKE_CASE_	) * beta(SCREAMING_SNAKE_CASE_	), 0, 0],
          [-gamma(SCREAMING_SNAKE_CASE_	) * beta(SCREAMING_SNAKE_CASE_	), gamma(SCREAMING_SNAKE_CASE_	), 0, 0],
          [0, 0, 1, 0],
          [0, 0, 0, 1],
      ]	)






def 		lowercase_(  SCREAMING_SNAKE_CASE_      ,						SCREAMING_SNAKE_CASE_ = None	):


  '''simple docstring'''

  if event is None:
    lowerCamelCase :					Tuple    =				np.array([ct, x, y, z]	)  # Symbolic four vector
  else:
    event[0] *= c  # x0 is ct (speed of light * time)

  return transformation_matrix(SCREAMING_SNAKE_CASE_	) @ event


if __name__ == "__main__":
   import doctest

   doctest.testmod()

   # Example of symbolic vector:
   _snake_case             =     transform(29_97_92_45)
   print('''Example of four vector: ''')
   print(f'''ct\' = {four_vector[0]}''')
   print(f'''x\' = {four_vector[1]}''')
   print(f'''y\' = {four_vector[2]}''')
   print(f'''z\' = {four_vector[3]}''')

   # Substitute symbols with numerical values
   _snake_case             =     {ct: c, x: 1, y: 1, z: 1}
   _snake_case             =     [four_vector[i].subs(sub_dict) for i in range(4)]

   print(f'''\n{numerical_vector}''')



