



from __future__ import annotations

from queue import Queue



class 		_lowercase		:

   def __init__(   self      :							Any				)							->					None:


    """simple docstring"""






    a							=		{}

   def 		A				(   self      :							Dict				)							->					None:


    """simple docstring"""






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

   def 		A				(   self      :							Dict				, __lowerCAmelCase      :							int				, __lowerCAmelCase      :							int				)							->					None:


    """simple docstring"""






    if from_vertex in self.vertices:
     self.vertices[from_vertex].append(__lowerCAmelCase				)
    else:
     a							=		[to_vertex]




   def 		A				(   self      :							List[Any]				, __lowerCAmelCase      :							int				)							->					set[int]:


    """simple docstring"""






    a							=		set()

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

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

    while not queue.empty():
     a							=		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_		:  Tuple										=  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  lowerCAmelCase__     (      _UpperCamelCase							:					list       )       ->					list:





						"""simple docstring"""






						if len(_UpperCamelCase       ) <= 1:
												return data
						else:
												return [
												    *quick_sort([e for e in data[1:] if e <= data[0]]       ),
												    data[0],
												    *quick_sort([e for e in data[1:] if e > data[0]]       ),
												]


if __name__ == "__main__":
					import doctest

					doctest.testmod()


