



from __future__ import annotations

def 			A_      (	__a     :				list[float] ,		__a     :				List[str]		):

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

def 			A_      (	__a     :				list[dict[str, int]] ,		__a     :				list[float] ,		__a     :				int		):

				"""simple docstring"""
				for j in range(__a		):
								a__      ,			a__      ,			a__				      =		(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 			A_      (	__a     :				list[dict[str, int]] ,		__a     :				int ,		__a     :				int ,		__a     :				int		):

				"""simple docstring"""
				a__				      =		[float("""inf"""		)] * vertex_count
				a__				      =		0.0

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

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

				a__				      =		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							 =					int(input("""Enter number of vertices: """).strip())
	UpperCAmelCase							 =					int(input("""Enter number of edges: """).strip())

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

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

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











from __future__ import annotations

UpperCAmelCase							 =					8.988E9  # units = N * m^s * C^-2

def 			A_      (	__a     :				float ,		__a     :				float ,		__a     :				float ,		__a     :				float		):

				"""simple docstring"""
				a__				      =		abs(chargea * chargea		)

				if (force, chargea, chargea, distance).count(0		) != 1:
								raise ValueError("""One and only one argument must be 0"""		)
				if distance < 0:
								raise ValueError("""Distance cannot be negative"""		)
				if force == 0:
								a__				      =		COULOMBS_CONSTANT * charge_product / (distance**2)
								return {"force": force}
				elif chargea == 0:
								a__				      =		abs(__a		) * (distance**2) / (COULOMBS_CONSTANT * chargea)
								return {"charge1": chargea}
				elif chargea == 0:
								a__				      =		abs(__a		) * (distance**2) / (COULOMBS_CONSTANT * chargea)
								return {"charge2": chargea}
				elif distance == 0:
								a__				      =		(COULOMBS_CONSTANT * charge_product / abs(__a		)) ** 0.5
								return {"distance": distance}
				raise ValueError("""Exactly one argument must be 0"""		)


if __name__ == "__main__":
	import doctest

	doctest.testmod()

