






class 						SCREAMING_SNAKE_CASE				:





							"""simple docstring"""

							def __init__(  self:   List[Any]   )    ->				Union[str, Any]:
												_A								= {}

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

							def       __A (  self:   Union[str, 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
																	_A								= [to_vertex]

							def       __A (  self:   Any   )    ->				None:
												# visited array for storing already visited nodes
												_A								= [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       __A (  self:   List[Any]		,     __A:   int		,     __A:   list   )    ->				None:
												# mark start vertex as visited
												_A								= 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__":
				__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()
				print('DFS:')
				g.dfs()

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











__A      =				{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

__A      =				{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}




def      __A					(     _lowercase					,			_lowercase					,			_lowercase ):

					'''simple docstring'''







					_A								= True
					_A								= []

					for neighbour in graph[vert]:
										if not visited[neighbour]:
															order += topology_sort(_lowercase					,			_lowercase					,			_lowercase )

					order.append(_lowercase )

					return order




def      __A					(     _lowercase					,			_lowercase					,			_lowercase ):

					'''simple docstring'''







					_A								= True
					_A								= [vert]

					for neighbour in reversed_graph[vert]:
										if not visited[neighbour]:
															component += find_components(_lowercase					,			_lowercase					,			_lowercase )

					return component




def      __A					(     _lowercase ):

					'''simple docstring'''







					_A								= len(_lowercase ) * [False]
					_A								= {vert: [] for vert in range(len(_lowercase ) )}

					for vert, neighbours in graph.items():
										for neighbour in neighbours:
															reversed_graph[neighbour].append(_lowercase )

					_A								= []
					for i, was_visited in enumerate(_lowercase ):
										if not was_visited:
															order += topology_sort(_lowercase					,			_lowercase					,			_lowercase )

					_A								= []
					_A								= len(_lowercase ) * [False]

					for i in range(len(_lowercase ) ):
										_A								= order[len(_lowercase ) - i - 1]
										if not visited[vert]:
															_A								= find_components(_lowercase					,			_lowercase					,			_lowercase )
															components_list.append(_lowercase )

					return components_list



