




'''simple docstring'''

from __future__ import annotations


def __UpperCAmelCase	(   _UpperCAmelCase		:   list[float]		,				_UpperCAmelCase		:   int						)      ->      List[Any]:
			print(F'''Vertex\tShortest Distance from vertex {src}'''						)
			for i, d in enumerate(_UpperCAmelCase						):
						print(F'''{i}\t\t{d}'''						)


def __UpperCAmelCase	(   _UpperCAmelCase		:   list[dict[str, int]]		,				_UpperCAmelCase		:   list[float]		,				_UpperCAmelCase		:   int						)      ->      Union[str, Any]:
			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 __UpperCAmelCase	(   _UpperCAmelCase		:   list[dict[str, int]]		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int		,				_UpperCAmelCase		:   int						)      ->      list[float]:
			__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()

						a       :						int								=		int(input('''Enter number of vertices: ''').strip())
						a       :						List[str]								=		int(input('''Enter number of edges: ''').strip())

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

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

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







'''simple docstring'''




lowercase     :							dict[str, float]       						=     {
    "joule": 1.0,
    "kilojoule": 10_00,
    "megajoule": 1_00_00_00,
    "gigajoule": 10_00_00_00_00,
    "wattsecond": 1.0,
    "watthour": 36_00,
    "kilowatthour": 3_60_00_00,
    "newtonmeter": 1.0,
    "calorie_nutr": 41_86.8,
    "kilocalorie_nutr": 4_18_68_00.00,
    "electronvolt": 1.6_02_17_66_34e-19,
    "britishthermalunit_it": 10_55.0_55_85,
    "footpound": 1.35_58_18,
}







def 						lowerCAmelCase_							(  snake_case__						,							snake_case__						,							snake_case__		):




    '''simple docstring'''



    if to_type not in ENERGY_CONVERSION or from_type not in ENERGY_CONVERSION:
        A			:  int   =		(
            F'Incorrect \'from_type\' or \'to_type\' value: {from_type!r}, {to_type!r}\n'
            F'Valid values are: {", ".join(snake_case__		)}'
        )
        raise ValueError(snake_case__		)
    return value * ENERGY_CONVERSION[from_type] / ENERGY_CONVERSION[to_type]


if __name__ == "__main__":
      import doctest

      doctest.testmod()




