code: 
  
  
  from __future__ import annotations
  
  from queue import Queue
  
  
  
  
  
  class 					snake_case__  :
  
  
  
  
  
  	def __init__(  self							)		->			None:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   dict[int, list[int]]			=	{}
  
  
  
  
  
  	def     A				(  self							)		->			None:
  								"""simple docstring"""
  
  
  
  
  
  
  								for i in self.vertices:
  															print(UpperCamelCase_				,    """ : """				,    """ -> """.join([str(UpperCamelCase_							) for j in self.vertices[i]]							)							)
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_				,    UpperCamelCase_							)		->			None:
  								"""simple docstring"""
  
  
  
  
  
  
  								if from_vertex in self.vertices:
  															self.vertices[from_vertex].append(UpperCamelCase_							)
  								else:
  															a_       :   List[str]			=	[to_vertex]
  
  
  
  
  
  	def     A				(  self				,    UpperCamelCase_							)		->			set[int]:
  								"""simple docstring"""
  
  
  
  
  
  
  								a_       :   Optional[Any]			=	set()
  
  								# create a first in first out queue to store all the vertices for BFS
  								a_       :   Queue			=	Queue()
  
  								# mark the source node as visited and enqueue it
  								visited.add(UpperCamelCase_							)
  								queue.put(UpperCamelCase_							)
  
  								while not queue.empty():
  															a_       :   List[Any]			=	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(UpperCamelCase_							)
  																													visited.add(UpperCamelCase_							)
  								return visited
  
  
  if __name__ == "__main__":
  			from doctest import testmod
  
  			testmod(verbose=True)
  
  			SCREAMING_SNAKE_CASE : List[str]          =    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]
  
  
  
style_context: 
  
  
  def 						_lowerCamelCase		(							SCREAMING_SNAKE_CASE_				: list[int]      ):
  
  
  
  
  
  
  							"""simple docstring"""
  
  
  
  							a_       :   List[Any]			=	len(SCREAMING_SNAKE_CASE_      )
  							if n in (0, 1):
  														return 0
  							return sum(query * (n - i - 1) for i, query in enumerate(sorted(SCREAMING_SNAKE_CASE_      )      )      )
  
  
  if __name__ == "__main__":
  	import doctest
  
  	doctest.testmod()
  
  
  