






from timeit import timeit







def 	_UpperCamelCase   (    UpperCamelCase_       :					int		)  ->   int:

						"""simple docstring"""



						if number < 0:
												raise ValueError('the value of input must not be negative'		)
						lowerCAmelCase__    						=						0
						while number:
												number &= number - 1
												result += 1
						return result







def 	_UpperCamelCase   (    UpperCamelCase_       :					int		)  ->   int:

						"""simple docstring"""



						if number < 0:
												raise ValueError('the value of input must not be negative'		)
						lowerCAmelCase__    						=						0
						while number:
												if number % 2 == 1:
																		result += 1
												number >>= 1
						return result







def 	_UpperCamelCase   (    )  ->   None:

						"""simple docstring"""



						def do_benchmark(UpperCamelCase_       :					int		) -> None:
												lowerCAmelCase__    						=						'import __main__ as z'
												print(F"Benchmark when {number = }:"		)
												print(F"{get_set_bits_count_using_modulo_operator(UpperCamelCase_		) = }"		)
												lowerCAmelCase__    						=						timeit('z.get_set_bits_count_using_modulo_operator(25)'    ,       setup=UpperCamelCase_		)
												print(F"timeit() runs in {timing} seconds"		)
												print(F"{get_set_bits_count_using_brian_kernighans_algorithm(UpperCamelCase_		) = }"		)
												lowerCAmelCase__    						=						timeit(
												    'z.get_set_bits_count_using_brian_kernighans_algorithm(25)'    ,       setup=UpperCamelCase_    ,       )
												print(F"timeit() runs in {timing} seconds"		)

						for number in (25, 37, 58, 0):
												do_benchmark(UpperCamelCase_		)
												print()


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					benchmark()







from __future__ import annotations

__snake_case    :    Any         =     {
    """A""": ["""B""", """C""", """E"""],
    """B""": ["""A""", """D""", """E"""],
    """C""": ["""A""", """F""", """G"""],
    """D""": ["""B"""],
    """E""": ["""A""", """B""", """D"""],
    """F""": ["""C"""],
    """G""": ["""C"""],
}


class     __SCREAMING_SNAKE_CASE					:






						def __init__(	self     ,						_UpperCamelCase     ,						_UpperCamelCase   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						graph
												# mapping node to its parent in resulting breadth first tree
												lowerCAmelCase__    						=						{}
												lowerCAmelCase__    						=						source_vertex






						def       UpperCamelCase__      (	self   ):






												"""simple docstring"""
												lowerCAmelCase__    						=						{self.source_vertex}
												lowerCAmelCase__    						=						None
												lowerCAmelCase__    						=						[self.source_vertex]  # first in first out queue

												while queue:
																		lowerCAmelCase__    						=						queue.pop(0   )
																		for adjacent_vertex in self.graph[vertex]:
																								if adjacent_vertex not in visited:
																														visited.add(_UpperCamelCase   )
																														lowerCAmelCase__    						=						vertex
																														queue.append(_UpperCamelCase   )







						def       UpperCamelCase__      (	self     ,						_UpperCamelCase   ):






												"""simple docstring"""
												if target_vertex == self.source_vertex:
																		return self.source_vertex

												lowerCAmelCase__    						=						self.parent.get(_UpperCamelCase   )
												if target_vertex_parent is None:
																		lowerCAmelCase__    						=						(
																		    F"No path from vertex: {self.source_vertex} to vertex: {target_vertex}"
																		)
																		raise ValueError(_UpperCamelCase   )

												return self.shortest_path(_UpperCamelCase   ) + F"->{target_vertex}"


if __name__ == "__main__":
					__snake_case    :    Optional[Any]         =     Graph(graph, """G""")
					g.breath_first_search()
					print(g.shortest_path("""D"""))
					print(g.shortest_path("""G"""))
					print(g.shortest_path("""Foo"""))





