
'''simple docstring'''



from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass




@dataclass
class     UpperCAmelCase_	:






						'''simple docstring'''






						_lowercase						: int
						_lowercase						: int






class     UpperCAmelCase_	:






						'''simple docstring'''






						def __init__(   self       ,  _lowercase ):

												"""simple docstring"""



												_lowerCAmelCase    		=					[[] for _ in range(_lowercase )]
												_lowerCAmelCase    		=					size




						def __getitem__(   self       ,  _lowercase ):

												"""simple docstring"""



												return iter(self._graph[vertex] )




						@property
						def    _lowercase      (   self ):

												"""simple docstring"""



												return self._size




						def    _lowercase      (   self       ,  _lowercase       ,  _lowercase       ,  _lowercase ):

												"""simple docstring"""



												if weight not in (0, 1):
																		raise ValueError("""Edge weight must be either 0 or 1.""" )

												if to_vertex < 0 or to_vertex >= self.size:
																		raise ValueError("""Vertex indexes must be in [0; size).""" )

												self._graph[from_vertex].append(Edge(_lowercase       ,  _lowercase ) )




						def    _lowercase      (   self       ,  _lowercase       ,  _lowercase ):

												"""simple docstring"""



												_lowerCAmelCase    		=					deque([start_vertex] )
												_lowerCAmelCase    		=					[None] * self.size
												_lowerCAmelCase    		=					0

												while queue:
																		_lowerCAmelCase    		=					queue.popleft()
																		_lowerCAmelCase    		=					distances[current_vertex]
																		if current_distance is None:
																								continue

																		for edge in self[current_vertex]:
																								_lowerCAmelCase    		=					current_distance + edge.weight
																								_lowerCAmelCase    		=					distances[edge.destination_vertex]
																								if (
																								    isinstance(_lowercase       ,  _lowercase )
																								    and new_distance >= dest_vertex_distance
																								):
																														continue
																								_lowerCAmelCase    		=					new_distance
																								if edge.weight == 0:
																														queue.appendleft(edge.destination_vertex )
																								else:
																														queue.append(edge.destination_vertex )

												if distances[finish_vertex] is None:
																		raise ValueError("""No path from start_vertex to finish_vertex.""" )

												return distances[finish_vertex]


if __name__ == "__main__":
						import doctest

						doctest.testmod()



'''simple docstring'''





import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey





class 		__SCREAMING_SNAKE_CASE							:







				def __init__(       self     :		Union[str, Any]		,					UpperCAmelCase__     :		Union[str, Any]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		int   ):
										'''simple docstring'''
										if dst_width < 0 or dst_height < 0:
																raise ValueError('''Destination width/height should be > 0'''   )

										lowercase :							Union[str, Any]    		=img
										lowercase :							Union[str, Any]    		=img.shape[1]
										lowercase :							str    		=img.shape[0]
										lowercase :							Union[str, Any]    		=dst_width
										lowercase :							str    		=dst_height

										lowercase :							str    		=self.src_w / self.dst_w
										lowercase :							Optional[Any]    		=self.src_h / self.dst_h

										lowercase :							int    		=(
										    np.ones((self.dst_h, self.dst_w, 3)		,					np.uinta   ) * 255
										)







				def  lowerCamelCase_	(       self     :		List[Any]   ):
										'''simple docstring'''
										for i in range(self.dst_h   ):
																for j in range(self.dst_w   ):
																						lowercase :							List[Any]    		=self.img[self.get_y(UpperCAmelCase__   )][self.get_x(UpperCAmelCase__   )]







				def  lowerCamelCase_	(       self     :		Tuple		,					UpperCAmelCase__     :		int   ):
										'''simple docstring'''
										return int(self.ratio_x * x   )







				def  lowerCamelCase_	(       self     :		List[Any]		,					UpperCAmelCase__     :		int   ):
										'''simple docstring'''
										return int(self.ratio_y * y   )


if __name__ == "__main__":
							UpperCamelCase_						,   UpperCamelCase_    						=       800, 600
							UpperCamelCase_    						=       imread("""image_data/lena.jpg""", 1)
							UpperCamelCase_    						=       NearestNeighbour(im, dst_w, dst_h)
							n.process()

							imshow(
							    f'''Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}''', n.output
							)
							waitKey(0)
							destroyAllWindows()





