



class 					_lowercase      :
				'''simple docstring'''







				def __init__(       self			):

									'''simple docstring'''


									UpperCamelCase_						     =      {}

				def 					_lowerCamelCase    (       self			):

									'''simple docstring'''


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

				def 					_lowerCamelCase    (       self   ,       snake_case__   ,       snake_case__			):

									'''simple docstring'''


									if from_vertex in self.vertex:
														self.vertex[from_vertex].append(snake_case__			)
									else:
														# else make a new vertex
														UpperCamelCase_						     =      [to_vertex]

				def 					_lowerCamelCase    (       self			):

									'''simple docstring'''


									UpperCamelCase_						     =      [False] * len(self.vertex			)

									# call the recursive helper function
									for i in range(len(self.vertex			)			):
														if not visited[i]:
																			self.dfs_recursive(snake_case__   ,       snake_case__			)

				def 					_lowerCamelCase    (       self   ,       snake_case__   ,       snake_case__			):

									'''simple docstring'''


									UpperCamelCase_						     =      True

									print(snake_case__   ,       end=" "			)

									# Recur for all the vertices that are adjacent to this node
									for i in self.vertex:
														if not visited[i]:
																			self.dfs_recursive(snake_case__   ,       snake_case__			)


if __name__ == "__main__":
	UpperCAmelCase      :							Dict							       =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()
	print("""DFS:""")
	g.dfs()

	# OUTPUT:
	# 0  ->  1 -> 2
	# 1  ->  2
	# 2  ->  0 -> 3
	# 3  ->  3
	# DFS:
	#  0 1 2 3


class  lowerCamelCase__							:




	'''simple docstring'''




	def __init__(					self		:int						)		-> Dict:
								__UpperCamelCase	:   Union[str, Any]			   =					{}







	def    _lowerCamelCase				(					self		:str						)		-> None:
								print(self.vertex						)
								for i in self.vertex:
															print(a     ,   " -> "     ,   " -> ".join([str(a						) for j in self.vertex[i]]						)						)







	def    _lowerCamelCase				(					self		:List[Any]     ,   a		:int     ,   a		:int						)		-> None:
								# check if vertex is already present,
								if from_vertex in self.vertex:
															self.vertex[from_vertex].append(a						)
								else:
															# else make a new vertex
															__UpperCamelCase	:   Optional[Any]			   =					[to_vertex]







	def    _lowerCamelCase				(					self		:Tuple						)		-> None:
								# visited array for storing already visited nodes
								__UpperCamelCase	:   Dict			   =					[False] * len(self.vertex						)

								# call the recursive helper function
								for i in range(len(self.vertex						)						):
															if not visited[i]:
																						self.dfs_recursive(a     ,   a						)







	def    _lowerCamelCase				(					self		:Any     ,   a		:int     ,   a		:list						)		-> None:
								# mark start vertex as visited
								__UpperCamelCase	:   int			   =					True

								print(a     ,   end=" "						)

								# Recur for all the vertices that are adjacent to this node
								for i in self.vertex:
															if not visited[i]:
																						self.dfs_recursive(a     ,   a						)


if __name__ == "__main__":
		lowercase  :					Dict													=       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()
		print('DFS:')
		g.dfs()

		# OUTPUT:
		# 0  ->  1 -> 2
		# 1  ->  2
		# 2  ->  0 -> 3
		# 3  ->  3
		# DFS:
		#  0 1 2 3