


# Author: OMKAR PATHAK, Nwachukwu Chidiebere

# Use a Python dictionary to construct the graph.
from __future__ import annotations

from pprint import pformat
from typing import Generic, TypeVar

__snake_case            =   TypeVar("T")




class    UpperCAmelCase					(       Generic[T]    ):




			def __init__(						self							:		Union[str, Any]       ,       __magic_name__							:		bool = True						):







						"""simple docstring"""







						UpperCamelCase         =					{}  # dictionary of lists
						UpperCamelCase         =					directed




			def   lowerCamelCase_					(						self							:		str       ,       __magic_name__							:		T       ,       __magic_name__							:		T						):







						"""simple docstring"""







						if not self.directed:  # For undirected graphs
									# if both source vertex and destination vertex are both present in the
									# adjacency list, add destination vertex to source vertex list of adjacent
									# vertices and add source vertex to destination vertex list of adjacent
									# vertices.
									if source_vertex in self.adj_list and destination_vertex in self.adj_list:
												self.adj_list[source_vertex].append(__magic_name__						)
												self.adj_list[destination_vertex].append(__magic_name__						)
									# if only source vertex is present in adjacency list, add destination vertex
									# to source vertex list of adjacent vertices, then create a new vertex with
									# destination vertex as key and assign a list containing the source vertex
									# as it's first adjacent vertex.
									elif source_vertex in self.adj_list:
												self.adj_list[source_vertex].append(__magic_name__						)
												UpperCamelCase         =					[source_vertex]
									# if only destination vertex is present in adjacency list, add source vertex
									# to destination vertex list of adjacent vertices, then create a new vertex
									# with source vertex as key and assign a list containing the source vertex
									# as it's first adjacent vertex.
									elif destination_vertex in self.adj_list:
												self.adj_list[destination_vertex].append(__magic_name__						)
												UpperCamelCase         =					[destination_vertex]
									# if both source vertex and destination vertex are not present in adjacency
									# list, create a new vertex with source vertex as key and assign a list
									# containing the destination vertex as it's first adjacent vertex also
									# create a new vertex with destination vertex as key and assign a list
									# containing the source vertex as it's first adjacent vertex.
									else:
												UpperCamelCase         =					[destination_vertex]
												UpperCamelCase         =					[source_vertex]
						else:  # For directed graphs
									# if both source vertex and destination vertex are present in adjacency
									# list, add destination vertex to source vertex list of adjacent vertices.
									if source_vertex in self.adj_list and destination_vertex in self.adj_list:
												self.adj_list[source_vertex].append(__magic_name__						)
									# if only source vertex is present in adjacency list, add destination
									# vertex to source vertex list of adjacent vertices and create a new vertex
									# with destination vertex as key, which has no adjacent vertex
									elif source_vertex in self.adj_list:
												self.adj_list[source_vertex].append(__magic_name__						)
												UpperCamelCase         =					[]
									# if only destination vertex is present in adjacency list, create a new
									# vertex with source vertex as key and assign a list containing destination
									# vertex as first adjacent vertex
									elif destination_vertex in self.adj_list:
												UpperCamelCase         =					[destination_vertex]
									# if both source vertex and destination vertex are not present in adjacency
									# list, create a new vertex with source vertex as key and a list containing
									# destination vertex as it's first adjacent vertex. Then create a new vertex
									# with destination vertex as key, which has no adjacent vertex
									else:
												UpperCamelCase         =					[destination_vertex]
												UpperCamelCase         =					[]

						return self





			def __repr__(						self							:		Any						):







						"""simple docstring"""







						return pformat(self.adj_list						)








def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		int	):





			"""simple docstring"""




			UpperCamelCase         =					int(SCREAMING_SNAKE_CASE_	)
			if decimal in (0, 1):  # Exit cases for the recursion
						return str(SCREAMING_SNAKE_CASE_	)
			UpperCamelCase  ,  UpperCamelCase         =					divmod(SCREAMING_SNAKE_CASE_       ,  2	)
			return binary_recursive(SCREAMING_SNAKE_CASE_	) + str(SCREAMING_SNAKE_CASE_	)






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		str	):





			"""simple docstring"""




			UpperCamelCase         =					str(SCREAMING_SNAKE_CASE_	).strip()
			if not number:
						raise ValueError("""No input value was provided"""	)
			UpperCamelCase         =					"""-""" if number.startswith("""-"""	) else """"""
			UpperCamelCase         =					number.lstrip("""-"""	)
			if not number.isnumeric():
						raise ValueError("""Input value is not an integer"""	)
			return f'{negative}0b{binary_recursive(int(SCREAMING_SNAKE_CASE_	)	)}'


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

			testmod()




