




'''simple docstring'''
from __future__ import annotations

from queue import Queue






class        SCREAMING_SNAKE_CASE:

       def __init__(    self     )    ->					None:

           """simple docstring"""



           __lowercase							=						{}

       def     snake_case__			(    self     )    ->					None:

           """simple docstring"""



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

       def     snake_case__			(    self					,		lowerCamelCase__					,		lowerCamelCase__     )    ->					None:

           """simple docstring"""



           if from_vertex in self.vertices:
               self.vertices[from_vertex].append(lowerCamelCase__     )
           else:
               __lowercase							=						[to_vertex]




       def     snake_case__			(    self					,		lowerCamelCase__     )    ->					set[int]:

           """simple docstring"""



           __lowercase							=						set()

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

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

           while not queue.empty():
               __lowercase							=						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							:      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()
  # 0  :  1 -> 2
  # 1  :  2
  # 2  :  0 -> 3
  # 3  :  3

  assert sorted(g.bfs(2)) == [0, 1, 2, 3]










'''simple docstring'''
def 				snake_case_  (   a__		:	int			):



    """simple docstring"""




    if not isinstance(a__    ,a__			) or number < 0:
        raise ValueError("""Input must be a non-negative integer"""			)

    __lowercase							=						number & ~(number - 1)
    __lowercase							=						0
    while intermediate:
        intermediate >>= 1
        index += 1
    return index - 1


if __name__ == "__main__":
  import doctest

  doctest.testmod(verbose=True)




