

"""simple docstring"""





from __future__ import annotations

def   __SCREAMING_SNAKE_CASE  (      A_						,     A_ ):
	print(f'Vertex\tShortest Distance from vertex {src}' )
	for i, d in enumerate(A_ ):
		print(f'{i}\t\t{d}' )

def   __SCREAMING_SNAKE_CASE  (      A_						,     A_						,     A_ ):
	for j in range(A_ ):
		lowerCAmelCase__				,lowerCAmelCase__				,lowerCAmelCase__	:						List[str]  				=	(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   __SCREAMING_SNAKE_CASE  (      A_						,     A_						,     A_						,     A_ ):
	lowerCAmelCase__	:						str  				=	[float('''inf''' )] * vertex_count
	lowerCAmelCase__	:						str  				=	0.0

	for _ in range(vertex_count - 1 ):
		for j in range(A_ ):
			lowerCAmelCase__				,lowerCAmelCase__				,lowerCAmelCase__	:						Optional[Any]  				=	(graph[j][k] for k in ['''src''', '''dst''', '''weight'''])

			if distance[u] != float('''inf''' ) and distance[u] + w < distance[v]:
				lowerCAmelCase__	:						Union[str, Any]  				=	distance[u] + w

	lowerCAmelCase__	:						List[str]  				=	check_negative_cycle(A_						,     A_						,     A_ )
	if negative_cycle_exists:
		raise Exception('''Negative cycle found''' )

	return distance


if __name__ == "__main__":
							import doctest

							doctest.testmod()

							__UpperCamelCase  :      Dict							      =		int(input('''Enter number of vertices: ''').strip())
							__UpperCamelCase  :      Any							      =		int(input('''Enter number of edges: ''').strip())

							__UpperCamelCase  :      list[dict[str, int]]							      =		[{} for _ in range(E)]

							for i in range(E):
														print('''Edge ''', i + 1)
														__UpperCamelCase      ,    __UpperCamelCase      ,    __UpperCamelCase  :      Union[str, Any]							      =		(
														    int(x)
														    for x in input('''Enter source, destination, weight: ''').strip().split(''' ''')
														)
														__UpperCamelCase  :      Optional[Any]							      =		{'''src''': src, '''dst''': dest, '''weight''': weight}

							__UpperCamelCase  :      Optional[Any]							      =		int(input('''\nEnter shortest path source:''').strip())
							__UpperCamelCase  :      Optional[Any]							      =		bellman_ford(graph, V, E, source)
							print_distance(shortest_distance, 0)







"""simple docstring"""





from ..utils import DummyObject, requires_backends







class 				SCREAMING_SNAKE_CASE					(		metaclass=a_       ):






					"""simple docstring"""



					lowercase__				 =       ["speech"]







					def __init__(       self			:				Tuple   ,*lowercase_			:				Tuple   ,**lowercase_			:				List[str]		):
						requires_backends(self   ,['''speech''']		)







class 				SCREAMING_SNAKE_CASE					(		metaclass=a_       ):






					"""simple docstring"""



					lowercase__				 =       ["speech"]







					def __init__(       self			:				Union[str, Any]   ,*lowercase_			:				List[str]   ,**lowercase_			:				Any		):
						requires_backends(self   ,['''speech''']		)




