"""simple docstring"""
from __future__ import annotations





def    lowerCAmelCase__    (			_UpperCamelCase       :				int ,			_UpperCamelCase       :				Tuple					)					->				List[str]:





      """simple docstring"""






      print(f"""Vertex\tShortest Distance from vertex {src}"""					)
      for i, d in enumerate(_UpperCamelCase					):
            print(f"""{i}\t\t{d}"""					)





def    lowerCAmelCase__    (			_UpperCamelCase       :				List[str] ,			_UpperCamelCase       :				Optional[int] ,			_UpperCamelCase       :				Optional[int]					)					->				Optional[int]:





      """simple docstring"""






      for j in range(_UpperCamelCase					):
            snake_case					,snake_case					,snake_case								=			(graph[j][k] for k in ['src', 'dst', 'weight'])
            if distance[u] != float('inf'					) and distance[u] + w < distance[v]:
                  return True
      return False





def    lowerCAmelCase__    (			_UpperCamelCase       :				str ,			_UpperCamelCase       :				List[Any] ,			_UpperCamelCase       :				Optional[int] ,			_UpperCamelCase       :				Tuple					)					->				Optional[int]:





      """simple docstring"""






      snake_case								=			[float('inf'					)] * vertex_count
      snake_case								=			0.0

      for _ in range(vertex_count - 1					):
            for j in range(_UpperCamelCase					):
                  snake_case					,snake_case					,snake_case								=			(graph[j][k] for k in ['src', 'dst', 'weight'])

                  if distance[u] != float('inf'					) and distance[u] + w < distance[v]:
                        snake_case								=			distance[u] + w

      snake_case								=			check_negative_cycle(_UpperCamelCase ,			_UpperCamelCase ,			_UpperCamelCase					)
      if negative_cycle_exists:
            raise Exception('Negative cycle found'					)

      return distance


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     SCREAMING_SNAKE_CASE__      						=  int(input("Enter number of vertices: ").strip())
     SCREAMING_SNAKE_CASE__      						=  int(input("Enter number of edges: ").strip())

     SCREAMING_SNAKE_CASE__      						=  [{} for _ in range(E)]

     for i in range(E):
          print("Edge ", i + 1)
          SCREAMING_SNAKE_CASE__      						=  (
              int(x)
              for x in input("Enter source, destination, weight: ").strip().split(" ")
          )
          SCREAMING_SNAKE_CASE__      						=  {"""src""": src, """dst""": dest, """weight""": weight}

     SCREAMING_SNAKE_CASE__      						=  int(input("\nEnter shortest path source:").strip())
     SCREAMING_SNAKE_CASE__      						=  bellman_ford(graph, V, E, source)
     print_distance(shortest_distance, 0)



"""simple docstring"""
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


SCREAMING_SNAKE_CASE__      						=  {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE__      						=  [
					    "SEW_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "SEWForCTC",
					    "SEWForSequenceClassification",
					    "SEWModel",
					    "SEWPreTrainedModel",
					]

if TYPE_CHECKING:
					from .configuration_sew import SEW_PRETRAINED_CONFIG_ARCHIVE_MAP, SEWConfig

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_sew import (
										    SEW_PRETRAINED_MODEL_ARCHIVE_LIST,
										    SEWForCTC,
										    SEWForSequenceClassification,
										    SEWModel,
										    SEWPreTrainedModel,
										)


else:
					import sys

					SCREAMING_SNAKE_CASE__      						=  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


