






'''simple docstring'''


from __future__ import annotations

from queue import Queue




class 							lowerCAmelCase					:







   """simple docstring"""







   def __init__( self			)    ->   None:
    __a    :	dict[int, list[int]]									=						{}



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



   def    __magic_name__    ( self   ,   _A   ,   _A			)    ->   None:
    if from_vertex in self.vertices:
     self.vertices[from_vertex].append(_A			)
    else:
     __a    :	Union[str, Any]									=						[to_vertex]



   def    __magic_name__    ( self   ,   _A			)    ->   set[int]:
    __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(_A			)
    queue.put(_A			)

    while not queue.empty():
     __a    :	Tuple									=						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(_A			)
       visited.add(_A			)
    return visited


if __name__ == "__main__":
  from doctest import testmod

  testmod(verbose=True)

  SCREAMING_SNAKE_CASE_				      =							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'''


import math
from timeit import timeit






def   lowerCAmelCase__			(					SCREAMING_SNAKE_CASE__		):
 __a    :	Any									=						0
 __a    :	List[Any]									=						abs(SCREAMING_SNAKE_CASE__		)
 while True:
  __a    :	int									=						n // 10
  digits += 1
  if n == 0:
   break
 return digits






def   lowerCAmelCase__			(					SCREAMING_SNAKE_CASE__		):
 return 1 if n == 0 else math.floor(math.log(abs(SCREAMING_SNAKE_CASE__		)       ,		10		) + 1		)






def   lowerCAmelCase__			(					SCREAMING_SNAKE_CASE__		):
 return len(str(abs(SCREAMING_SNAKE_CASE__		)		)		)






def   lowerCAmelCase__			(					):
 from collections.abc import Callable

 def benchmark_a_function(SCREAMING_SNAKE_CASE__       ,		SCREAMING_SNAKE_CASE__		) -> None:
  __a    :	Tuple									=						f'''{func.__name__}({value})'''
  __a    :	List[Any]									=						timeit(f'''__main__.{call}'''       ,		setup='import __main__'		)
  print(f'''{call}: {func(SCREAMING_SNAKE_CASE__		)} -- {timing} seconds'''		)

 for value in (262144, 1125899906842624, 1267650600228229401496703205376):
  for func in (num_digits, num_digits_fast, num_digits_faster):
   benchmark_a_function(SCREAMING_SNAKE_CASE__       ,		SCREAMING_SNAKE_CASE__		)
  print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()




