


"""simple docstring"""





from __future__ import annotations

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

@dataclass
class 			lowercase_	:
      __magic_name__  :				int
      __magic_name__  :				int

class 			lowercase_	:







      def __init__(   self			:				Tuple		,	_lowercase			:				int     ):
        lowerCAmelCase__     :     List[str]										=       [[] for _ in range(_lowercase     )]
        lowerCAmelCase__     :     Tuple										=       size







      def __getitem__(   self			:				List[Any]		,	_lowercase			:				int     ):
        return iter(self._graph[vertex]     )







      @property
      def 					_lowerCAmelCase							(   self			:				Optional[int]     ):
        return self._size







      def 					_lowerCAmelCase							(   self			:				Any		,	_lowercase			:				int		,	_lowercase			:				int		,	_lowercase			:				int     ):

        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 					_lowerCAmelCase							(   self			:				Optional[Any]		,	_lowercase			:				int		,	_lowercase			:				int     ):
        lowerCAmelCase__     :     Union[str, Any]										=       deque([start_vertex]     )
        lowerCAmelCase__     :     Dict										=       [None] * self.size
        lowerCAmelCase__     :     Optional[int]										=       0

        while queue:
          lowerCAmelCase__     :     Tuple										=       queue.popleft()
          lowerCAmelCase__     :     List[str]										=       distances[current_vertex]
          if current_distance is None:
            continue

          for edge in self[current_vertex]:
            lowerCAmelCase__     :     List[Any]										=       current_distance + edge.weight
            lowerCAmelCase__     :     Optional[int]										=       distances[edge.destination_vertex]
            if (
                isinstance(_lowercase		,	_lowercase     )
                and new_distance >= dest_vertex_distance
            ):
              continue
            lowerCAmelCase__     :     int										=       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()




import baseaa





def 						_lowerCAmelCase							(     _lowerCAmelCase			)    ->						bytes:


						'''simple docstring'''






						return baseaa.baaencode(string.encode("utf-8"			)			)





def 						_lowerCAmelCase							(     _lowerCAmelCase			)    ->						str:


						'''simple docstring'''






						return baseaa.baadecode(_lowerCAmelCase			).decode("utf-8"			)


if __name__ == "__main__":
	A				:       Dict      =  'Hello World!'
	A				:       Any      =  baseaa_encode(test)
	print(encoded)

	A				:       Optional[int]      =  baseaa_decode(encoded)
	print(decoded)





