'''simple docstring'''




from __future__ import annotations





class        __magic_name__		:







			def __init__(      self							:    List[str]							,     lowercase_							:    int       ):
										lowercase_   :     List[str]									=			vertices
										lowercase_   :     Optional[Any]									=			[[0] * vertices for _ in range(lowercase_       )]







			def       SCREAMING_SNAKE_CASE_	(      self							:    int							,     lowercase_							:    list[int]       ):
										print("""Vertex \t Distance from Source"""       )
										for vertex in range(self.vertices       ):
																	print(lowercase_							,     """\t\t"""							,     distances_from_source[vertex]       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    str							,     lowercase_							:    list[int]							,     lowercase_							:    list[bool]       ):
										lowercase_   :     Dict									=			1E7
										lowercase_   :     int									=			0

										# Search not nearest vertex not in the shortest path tree
										for vertex in range(self.vertices       ):
																	if distances_from_source[vertex] < minimum and visited[vertex] is False:
																								lowercase_   :     Tuple									=			distances_from_source[vertex]
																								lowercase_   :     str									=			vertex
										return min_index







			def       SCREAMING_SNAKE_CASE_	(      self							:    Union[str, Any]							,     lowercase_							:    int       ):
										lowercase_   :     Optional[Any]									=			[int(1E7       )] * self.vertices  # distances from the source
										lowercase_   :     List[Any]									=			0
										lowercase_   :     Any									=			[False] * self.vertices

										for _ in range(self.vertices       ):
																	lowercase_   :     Tuple									=			self.minimum_distance(lowercase_							,     lowercase_       )
																	lowercase_   :     Union[str, Any]									=			True

																	# Update dist value of the adjacent vertices
																	# of the picked vertex only if the current
																	# distance is greater than new distance and
																	# the vertex in not in the shortest path tree
																	for v in range(self.vertices       ):
																								if (
																								    self.graph[u][v] > 0
																								    and visited[v] is False
																								    and distances[v] > distances[u] + self.graph[u][v]
																								):
																															lowercase_   :     Any									=			distances[u] + self.graph[u][v]

										self.print_solution(lowercase_       )


if __name__ == "__main__":
						_lowercase		:					Any													=		Graph(9)
						_lowercase		:					Any													=		[
						    [0, 4, 0, 0, 0, 0, 0, 8, 0],
						    [4, 0, 8, 0, 0, 0, 0, 11, 0],
						    [0, 8, 0, 7, 0, 4, 0, 0, 2],
						    [0, 0, 7, 0, 9, 14, 0, 0, 0],
						    [0, 0, 0, 9, 0, 10, 0, 0, 0],
						    [0, 0, 4, 14, 10, 0, 2, 0, 0],
						    [0, 0, 0, 0, 0, 2, 0, 1, 6],
						    [8, 11, 0, 0, 0, 0, 1, 0, 7],
						    [0, 0, 2, 0, 0, 0, 6, 7, 0],
						]
						graph.dijkstra(0)






'''simple docstring'''




from __future__ import annotations





class        __magic_name__		:







			def __init__(      self							:    List[str]							,     lowercase_							:    int       ):
										lowercase_   :     List[str]									=			vertices
										lowercase_   :     Optional[Any]									=			[[0] * vertices for _ in range(lowercase_       )]







			def       SCREAMING_SNAKE_CASE_	(      self							:    int							,     lowercase_							:    list[int]       ):
										print("""Vertex \t Distance from Source"""       )
										for vertex in range(self.vertices       ):
																	print(lowercase_							,     """\t\t"""							,     distances_from_source[vertex]       )







			def       SCREAMING_SNAKE_CASE_	(      self							:    str							,     lowercase_							:    list[int]							,     lowercase_							:    list[bool]       ):
										lowercase_   :     Dict									=			1E7
										lowercase_   :     int									=			0

										# Search not nearest vertex not in the shortest path tree
										for vertex in range(self.vertices       ):
																	if distances_from_source[vertex] < minimum and visited[vertex] is False:
																								lowercase_   :     Tuple									=			distances_from_source[vertex]
																								lowercase_   :     str									=			vertex
										return min_index







			def       SCREAMING_SNAKE_CASE_	(      self							:    Union[str, Any]							,     lowercase_							:    int       ):
										lowercase_   :     Optional[Any]									=			[int(1E7       )] * self.vertices  # distances from the source
										lowercase_   :     List[Any]									=			0
										lowercase_   :     Any									=			[False] * self.vertices

										for _ in range(self.vertices       ):
																	lowercase_   :     Tuple									=			self.minimum_distance(lowercase_							,     lowercase_       )
																	lowercase_   :     Union[str, Any]									=			True

																	# Update dist value of the adjacent vertices
																	# of the picked vertex only if the current
																	# distance is greater than new distance and
																	# the vertex in not in the shortest path tree
																	for v in range(self.vertices       ):
																								if (
																								    self.graph[u][v] > 0
																								    and visited[v] is False
																								    and distances[v] > distances[u] + self.graph[u][v]
																								):
																															lowercase_   :     Any									=			distances[u] + self.graph[u][v]

										self.print_solution(lowercase_       )


if __name__ == "__main__":
						_lowercase		:					Any													=		Graph(9)
						_lowercase		:					Any													=		[
						    [0, 4, 0, 0, 0, 0, 0, 8, 0],
						    [4, 0, 8, 0, 0, 0, 0, 11, 0],
						    [0, 8, 0, 7, 0, 4, 0, 0, 2],
						    [0, 0, 7, 0, 9, 14, 0, 0, 0],
						    [0, 0, 0, 9, 0, 10, 0, 0, 0],
						    [0, 0, 4, 14, 10, 0, 2, 0, 0],
						    [0, 0, 0, 0, 0, 2, 0, 1, 6],
						    [8, 11, 0, 0, 0, 0, 1, 0, 7],
						    [0, 0, 2, 0, 0, 0, 6, 7, 0],
						]
						graph.dijkstra(0)





