





from __future__ import annotations

from collections import deque
from queue import Queue
from timeit import timeit

UpperCAmelCase_       : int							=    {
    """A""": ["""B""", """C"""],
    """B""": ["""A""", """D""", """E"""],
    """C""": ["""A""", """F"""],
    """D""": ["""B"""],
    """E""": ["""B""", """F"""],
    """F""": ["""C""", """E"""],
}






def 				_lowerCAmelCase			(	_a :       dict       , _a :       str      )						->      list[str]:
     lowerCAmelCase_       :							Union[str, Any]			 =		{start}
     lowerCAmelCase_       :							Tuple			 =		[start]
     lowerCAmelCase_       :							Queue			 =		Queue()
     queue.put(_a      )
     while not queue.empty():
          lowerCAmelCase_       :							str			 =		queue.get()
          for w in graph[v]:
               if w not in explored:
                    explored.add(_a      )
                    result.append(_a      )
                    queue.put(_a      )
     return result






def 				_lowerCAmelCase			(	_a :       dict       , _a :       str      )						->      list[str]:
     lowerCAmelCase_       :							int			 =		{start}
     lowerCAmelCase_       :							Optional[int]			 =		[start]
     lowerCAmelCase_       :							Any			 =		deque([start]      )
     while queue:
          lowerCAmelCase_       :							Any			 =		queue.popleft()
          for child in graph[v]:
               if child not in visited:
                    visited.add(_a      )
                    result.append(_a      )
                    queue.append(_a      )
     return result






def 				_lowerCAmelCase			(	_a :       str      )						->      None:
     lowerCAmelCase_       :							List[str]			 =		F'from __main__ import G, {name}'
     lowerCAmelCase_       :							List[Any]			 =		1_00_00
     lowerCAmelCase_       :							Tuple			 =		timeit(F'{name}(G, \'A\')'       , setup=_a       , number=_a      )
     print(F'{name:<35} finished {number} runs in {res:.5f} seconds'      )


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      benchmark_function("""breadth_first_search""")
      benchmark_function("""breadth_first_search_with_deque""")
      # breadth_first_search                finished 10000 runs in 0.20999 seconds
      # breadth_first_search_with_deque     finished 10000 runs in 0.01421 seconds







def 				_lowerCAmelCase			(	_a :       str      )						->      int:
     lowerCAmelCase_       :							List[str]			 =		53_81
     for x in s:
          lowerCAmelCase_       :							Dict			 =		((hash_value << 5) + hash_value) + ord(_a      )
     return hash_value & 0XFFFFFFFF
