





from __future__ import annotations




def 					lowercase__    (					lowercase_		,lowercase_			)					->		int:




      """simple docstring"""

      print(F'''Vertex\tShortest Distance from vertex {src}'''			)
      for i, d in enumerate(lowercase_			):
            print(F'''{i}\t\t{d}'''			)




def 					lowercase__    (					lowercase_		,lowercase_		,lowercase_			)					->		List[Any]:




      """simple docstring"""

      for j in range(lowercase_			):
            _UpperCamelCase,  _UpperCamelCase,  _UpperCamelCase      :	Dict						=       (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 					lowercase__    (					lowercase_		,lowercase_		,lowercase_		,lowercase_			)					->		Dict:




      """simple docstring"""

      _UpperCamelCase      :	List[str]						=       [float("inf"			)] * vertex_count
      _UpperCamelCase      :	int						=       0.0

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

                  if distance[u] != float("inf"			) and distance[u] + w < distance[v]:
                        _UpperCamelCase      :	List[str]						=       distance[u] + w

      _UpperCamelCase      :	Optional[int]						=       check_negative_cycle(lowercase_		,lowercase_		,lowercase_			)
      if negative_cycle_exists:
            raise Exception("Negative cycle found"			)

      return distance


if __name__ == "__main__":
  import doctest

  doctest.testmod()

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

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

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

  lowerCamelCase__				  =   int(input("\nEnter shortest path source:").strip())
  lowerCamelCase__				  =   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, is_vision_available


lowerCamelCase__				  =   {
    "configuration_mask2former": [
        "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "Mask2FormerConfig",
    ],
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowerCamelCase__				  =   ["Mask2FormerImageProcessor"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowerCamelCase__				  =   [
      "MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "Mask2FormerForUniversalSegmentation",
      "Mask2FormerModel",
      "Mask2FormerPreTrainedModel",
  ]

if TYPE_CHECKING:
  from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_maskaformer import MaskaFormerImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_maskaformer import (
        MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        MaskaFormerForUniversalSegmentation,
        MaskaFormerModel,
        MaskaFormerPreTrainedModel,
    )


else:
  import sys

  lowerCamelCase__				  =   _LazyModule(__name__, globals()["__file__"], _import_structure)
