






from __future__ import annotations







class  lowerCamelCase_   :
							def __init__(  self						:    Any							,__lowerCamelCase						:    int    ):





								'''simple docstring'''



								a				=	vertices
								a				=	[[0] * vertices for _ in range(lowercase__    )]
							def        SCREAMING_SNAKE_CASE_       (  self						:    Union[str, Any]							,__lowerCamelCase						:    list[int]    ):





								'''simple docstring'''



								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						:    Optional[Any]							,__lowerCamelCase						:    list[int]							,__lowerCamelCase						:    list[bool]    ):





								'''simple docstring'''



								a				=	1e7
								a				=	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:
										a				=	distances_from_source[vertex]
										a				=	vertex
								return min_index




							def        SCREAMING_SNAKE_CASE_       (  self						:    List[str]							,__lowerCamelCase						:    int    ):





								'''simple docstring'''



								a				=	[int(1e7    )] * self.vertices  # distances from the source
								a				=	0
								a				=	[False] * self.vertices

								for _ in range(self.vertices    ):
									a				=	self.minimum_distance(lowercase__							,lowercase__    )
									a				=	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]
										):
											a				=	distances[u] + self.graph[u][v]

								self.print_solution(lowercase__    )


if __name__ == "__main__":
				UpperCamelCase__  :					Tuple  						=    Graph(9)
				UpperCamelCase__  :					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)






import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


lowerCAmelCase__							= datasets.utils.logging.get_logger(__name__)
@dataclass
class 				a_ (						datasets.BuilderConfig						):






 '''simple docstring'''






 UpperCAmelCase_	 =					None






class 				a_ (						datasets.ArrowBasedBuilder						):






 '''simple docstring'''






 UpperCAmelCase_	 =					ArrowConfig




 def 		__snake_case						(			self					:  Any):







        '''simple docstring'''



        return datasets.DatasetInfo(features=self.config.features)




 def 		__snake_case						(			self					:  Dict			,    lowercase__					:  str):







        '''simple docstring'''



        if not self.config.data_files:
               raise ValueError(F"""At least one data file must be specified, but got data_files={self.config.data_files}""")
        lowerCAmelCase__     	=					dl_manager.download_and_extract(self.config.data_files)
        if isinstance(lowercase__			,    (str, list, tuple)):
               lowerCAmelCase__     	=					data_files
               if isinstance(lowercase__			,    lowercase__):
                      lowerCAmelCase__     	=					[files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               lowerCAmelCase__     	=					[dl_manager.iter_files(lowercase__) for file in files]
               return [datasets.SplitGenerator(name=datasets.Split.TRAIN			,    gen_kwargs={'files': files})]
        lowerCAmelCase__     	=					[]
        for split_name, files in data_files.items():
               if isinstance(lowercase__			,    lowercase__):
                      lowerCAmelCase__     	=					[files]
               # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
               lowerCAmelCase__     	=					[dl_manager.iter_files(lowercase__) for file in files]
               # Infer features is they are stoed in the arrow schema
               if self.info.features is None:
                      for file in itertools.chain.from_iterable(lowercase__):
                             with open(lowercase__			,    'rb') as f:
                                    lowerCAmelCase__     	=					datasets.Features.from_arrow_schema(pa.ipc.open_stream(lowercase__).schema)
                             break
               splits.append(datasets.SplitGenerator(name=lowercase__			,    gen_kwargs={'files': files}))
        return splits




 def 		__snake_case						(			self					:  Dict			,    lowercase__					:  pa.Table):







        '''simple docstring'''



        if self.info.features is not None:
               # more expensive cast to support nested features with keys in a different order
               # allows str <-> int/float or str to Audio for example
               lowerCAmelCase__     	=					table_cast(lowercase__			,    self.info.features.arrow_schema)
        return pa_table




 def 		__snake_case						(			self					:  List[Any]			,    lowercase__					:  str):







        '''simple docstring'''



        for file_idx, file in enumerate(itertools.chain.from_iterable(lowercase__)):
               with open(lowercase__			,    'rb') as f:
                      try:
                             for batch_idx, record_batch in enumerate(pa.ipc.open_stream(lowercase__)):
                                    lowerCAmelCase__     	=					pa.Table.from_batches([record_batch])
                                    # Uncomment for debugging (will print the Arrow table size and elements)
                                    # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                                    # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                                    yield F"""{file_idx}_{batch_idx}""", self._cast_table(lowercase__)
                      except ValueError as e:
                             logger.error(F"""Failed to read file '{file}' with error {type(lowercase__)}: {e}""")
                             raise
