




from __future__ import annotations




def 							_UpperCAmelCase  (UpperCamelCase_ : list[float]      ,    UpperCamelCase_ : Tuple       ):
				'''simple docstring'''
				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       ):
				'''simple docstring'''
				for j in range(UpperCamelCase_       ):
								_lowerCAmelCase					,    _lowerCAmelCase					,    _lowerCAmelCase    :    Union[str, Any]										=      (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       ):
				'''simple docstring'''
				_lowerCAmelCase    :    Optional[int]										=      [float("""inf"""       )] * vertex_count
				_lowerCAmelCase    :    str										=      0.0

				for _ in range(vertex_count - 1       ):
								for j in range(UpperCamelCase_       ):
												_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    :    Any										=      check_negative_cycle(UpperCamelCase_      ,    UpperCamelCase_      ,    UpperCamelCase_       )
				if negative_cycle_exists:
								raise Exception("""Negative cycle found"""       )

				return distance


if __name__ == "__main__":
	import doctest

	doctest.testmod()

	_lowerCamelCase      :  List[Any]      						=						int(input("Enter number of vertices: ").strip())
	_lowerCamelCase      :  Optional[Any]      						=						int(input("Enter number of edges: ").strip())

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

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

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







import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression

# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split

# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures

# Importing the dataset
_lowerCamelCase      :  Dict      						=						pd.read_csv(
    "https://s3.us-west-2.amazonaws.com/public.gamelab.fun/dataset/"
    "position_salaries.csv"
)
_lowerCamelCase      :  Union[str, Any]      						=						dataset.iloc[:, 1:2].values
_lowerCamelCase      :  Any      						=						dataset.iloc[:, 2].values


_lowerCamelCase						, _lowerCamelCase						, _lowerCamelCase						, _lowerCamelCase      :  Optional[int]      						=						train_test_split(X, y, test_size=0.2, random_state=0)


_lowerCamelCase      :  Optional[Any]      						=						PolynomialFeatures(degree=4)
_lowerCamelCase      :  Optional[Any]      						=						poly_reg.fit_transform(X)
_lowerCamelCase      :  Dict      						=						LinearRegression()
pol_reg.fit(X_poly, y)




def 							_UpperCAmelCase  ():
				'''simple docstring'''
				plt.scatter(UpperCamelCase_      ,    UpperCamelCase_      ,    color="""red"""       )
				plt.plot(UpperCamelCase_      ,    pol_reg.predict(poly_reg.fit_transform(UpperCamelCase_       )       )      ,    color="""blue"""       )
				plt.title("""Truth or Bluff (Linear Regression)"""       )
				plt.xlabel("""Position level"""       )
				plt.ylabel("""Salary"""       )
				plt.show()


if __name__ == "__main__":
	viz_polymonial()

	# Predicting a new result with Polymonial Regression
	pol_reg.predict(poly_reg.fit_transform([[5.5]]))
	# output should be 132148.43750003

