


from __future__ import annotations

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

@dataclass
class   A__ :







    """simple docstring"""

    __magic_name__        =		42
    __magic_name__        =		42






class   A__ :







    """simple docstring"""

    def __init__(	self      , __snake_case      ):
         snake_case					=    [[] for _ in range(SCREAMING_SNAKE_CASE_      )]
         snake_case					=    size
    def __getitem__(	self      , __snake_case      ):
         return iter(self._graph[vertex]      )
    @property
    def 		a_      (	self      ):
         return self._size
    def 		a_      (	self      , __snake_case      , __snake_case      , __snake_case      ):
         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(SCREAMING_SNAKE_CASE_      , SCREAMING_SNAKE_CASE_      )      )




    def 		a_      (	self      , __snake_case      , __snake_case      ):
         snake_case					=    deque([start_vertex]      )
         snake_case					=    [None] * self.size
         snake_case					=    0

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

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








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_SCREAMING_SNAKE_CASE      :			int      				=   {
    "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _SCREAMING_SNAKE_CASE      :			Dict      				=   [
     "TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TimesformerModel",
     "TimesformerForVideoClassification",
     "TimesformerPreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_timesformer import TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, TimesformerConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_timesformer import (
      TIMESFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
      TimesformerForVideoClassification,
      TimesformerModel,
      TimesformerPreTrainedModel,
  )

else:
 import sys

 _SCREAMING_SNAKE_CASE      :			int      				=   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




