


'''simple docstring'''

from __future__ import annotations

from queue import Queue





class 					snake_case   :





  """simple docstring"""




  def __init__(   self					):







   """simple docstring"""
   lowerCamelCase_								=  {}






  def   snake_case		(   self					):







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






  def   snake_case		(   self      ,  UpperCamelCase      ,  UpperCamelCase					):







   """simple docstring"""
   if from_vertex in self.vertices:
    self.vertices[from_vertex].append(UpperCamelCase					)
   else:
    lowerCamelCase_								=  [to_vertex]







  def   snake_case		(   self      ,  UpperCamelCase					):







   """simple docstring"""
   lowerCamelCase_								=  set()

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

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

   while not queue.empty():
    lowerCamelCase_								=  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)

     a_  :    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]







'''simple docstring'''

class 					snake_case   :





  """simple docstring"""




  def __init__(   self      ,  UpperCamelCase					):







   """simple docstring"""
   lowerCamelCase_								=  data
   lowerCamelCase_								=  None
   lowerCamelCase_								=  None





def __snake_case (				UpperCAmelCase_						:						BinaryTreeNode | None ,    UpperCAmelCase_						:						int		):
 if node is None:
  lowerCamelCase_								=  BinaryTreeNode(UpperCAmelCase_		)
  return node

 # binary search tree is not empty,
 # so we will insert it into the tree
 # if new_value is less than value of data in node,
 #  add it to left subtree and proceed recursively
 if new_value < node.data:
  lowerCamelCase_								=  insert(node.left_child ,    UpperCAmelCase_		)
 else:
  # if new_value is greater than value of data in node,
  #  add it to right subtree and proceed recursively
  lowerCamelCase_								=  insert(node.right_child ,    UpperCAmelCase_		)
 return node





def __snake_case (				UpperCAmelCase_						:						None | BinaryTreeNode		):  # if node is None,return
 if node:
  lowerCamelCase_								=  inorder(node.left_child		)
  lowerCamelCase_								=  [*inorder_array, node.data]
  lowerCamelCase_								=  inorder_array + inorder(node.right_child		)
 else:
  lowerCamelCase_								=  []
 return inorder_array





def __snake_case (				):
 lowerCamelCase_								=  insert(UpperCAmelCase_ ,    15		)
 insert(UpperCAmelCase_ ,    10		)
 insert(UpperCAmelCase_ ,    25		)
 insert(UpperCAmelCase_ ,    6		)
 insert(UpperCAmelCase_ ,    14		)
 insert(UpperCAmelCase_ ,    20		)
 insert(UpperCAmelCase_ ,    60		)
 return root





def __snake_case (				):
 # main function
 lowerCamelCase_								=  make_tree()
 print("Printing values of binary search tree in Inorder Traversal."		)
 inorder(UpperCAmelCase_		)


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()



