
'''simple docstring'''



from __future__ import annotations

from queue import Queue





class      A							:



			def __init__(   self    )     ->						None:




									'''simple docstring'''



									lowercase__								=    {}



			def A__	(   self    )     ->						None:




									'''simple docstring'''



									for i in self.vertices:
															print(lowerCamelCase__    ,       """ : """    ,       """ -> """.join([str(lowerCamelCase__    ) for j in self.vertices[i]]    )    )



			def A__	(   self    ,       lowerCamelCase__    ,       lowerCamelCase__    )     ->						None:




									'''simple docstring'''



									if from_vertex in self.vertices:
															self.vertices[from_vertex].append(lowerCamelCase__    )
									else:
															lowercase__								=    [to_vertex]



			def A__	(   self    ,       lowerCamelCase__    )     ->						set[int]:




									'''simple docstring'''



									lowercase__								=    set()

									# create a first in first out queue to store all the vertices for BFS
									lowercase__								=    Queue()

									# mark the source node as visited and enqueue it
									visited.add(lowerCamelCase__    )
									queue.put(lowerCamelCase__    )

									while not queue.empty():
															lowercase__								=    queue.get()

															# loop through all adjacent vertex and enqueue it if not yet visited
															for adjacent_vertex in self.vertices[vertex]:
																					if adjacent_vertex not in visited:
																											queue.put(lowerCamelCase__    )
																											visited.add(lowerCamelCase__    )
									return visited


if __name__ == "__main__":
				from doctest import testmod

				testmod(verbose=True)

				__A       =      Graph()
				g.add_edge(0, 1)
				g.add_edge(0, 2)
				g.add_edge(1, 2)
				g.add_edge(2, 0)
				g.add_edge(2, 3)
				g.add_edge(3, 3)

				g.print_graph()
				# 0  :  1 -> 2
				# 1  :  2
				# 2  :  0 -> 3
				# 3  :  3

				assert sorted(g.bfs(2)) == [0, 1, 2, 3]








'''simple docstring'''



def 	_A						(							lowercase__		):
						if not isinstance(lowercase__						,						lowercase__		):
												raise ValueError("""Input series is not valid, valid series - [1, 2/3, 2]"""		)
						if len(lowercase__		) == 0:
												raise ValueError("""Input list must be a non empty list"""		)
						if len(lowercase__		) == 1 and series[0] != 0:
												return True
						lowercase__								=    []
						lowercase__								=    len(lowercase__		)
						for i in range(0						,						lowercase__		):
												if series[i] == 0:
																		raise ValueError("""Input series cannot have 0 as an element"""		)
												rec_series.append(1 / series[i]		)
						lowercase__								=    rec_series[1] - rec_series[0]
						for index in range(2						,						lowercase__		):
												if rec_series[index] - rec_series[index - 1] != common_diff:
																		return False
						return True





def 	_A						(							lowercase__		):
						if not isinstance(lowercase__						,						lowercase__		):
												raise ValueError("""Input series is not valid, valid series - [2, 4, 6]"""		)
						if len(lowercase__		) == 0:
												raise ValueError("""Input list must be a non empty list"""		)
						lowercase__								=    0
						for val in series:
												answer += 1 / val
						return len(lowercase__		) / answer


if __name__ == "__main__":
				import doctest

				doctest.testmod()






