


from abc import ABC, abstractmethod
from typing import Optional, Union

from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit
from ..utils.typing import NestedDataStructureLike, PathLike





class  _a							(    _lowercase):




	def __init__( self						:		Dict		, _SCREAMING_SNAKE_CASE						:		Optional[NestedDataStructureLike[PathLike]] = None		, _SCREAMING_SNAKE_CASE						:		Optional[NamedSplit] = None		, _SCREAMING_SNAKE_CASE						:		Optional[Features] = None		, _SCREAMING_SNAKE_CASE						:		str = None		, _SCREAMING_SNAKE_CASE						:		bool = False		, _SCREAMING_SNAKE_CASE						:		bool = False		, _SCREAMING_SNAKE_CASE						:		Optional[int] = None		, **_SCREAMING_SNAKE_CASE						:		Tuple		, )->	int:
			lowerCAmelCase__       :      Tuple   					= path_or_paths
			lowerCAmelCase__       :      Optional[Any]   					= split if split or isinstance(_SCREAMING_SNAKE_CASE		, _SCREAMING_SNAKE_CASE		) else '''train'''
			lowerCAmelCase__       :      Optional[int]   					= features
			lowerCAmelCase__       :      Union[str, Any]   					= cache_dir
			lowerCAmelCase__       :      Dict   					= keep_in_memory
			lowerCAmelCase__       :      Dict   					= streaming
			lowerCAmelCase__       :      Any   					= num_proc
			lowerCAmelCase__       :      str   					= kwargs




	@abstractmethod
	def 							UpperCAmelCase__( self						:		str		)->	Union[Dataset, DatasetDict, IterableDataset, IterableDatasetDict]:
			pass





class  _a							(    _lowercase):




	def __init__( self						:		int		, _SCREAMING_SNAKE_CASE						:		Optional[Features] = None		, _SCREAMING_SNAKE_CASE						:		str = None		, _SCREAMING_SNAKE_CASE						:		bool = False		, _SCREAMING_SNAKE_CASE						:		bool = False		, _SCREAMING_SNAKE_CASE						:		Optional[int] = None		, **_SCREAMING_SNAKE_CASE						:		int		, )->	List[str]:
			lowerCAmelCase__       :      int   					= features
			lowerCAmelCase__       :      Optional[Any]   					= cache_dir
			lowerCAmelCase__       :      List[str]   					= keep_in_memory
			lowerCAmelCase__       :      Any   					= streaming
			lowerCAmelCase__       :      int   					= num_proc
			lowerCAmelCase__       :      Any   					= kwargs




	@abstractmethod
	def 							UpperCAmelCase__( self						:		int		)->	Union[Dataset, IterableDataset]:
			pass








import math





class  _a							:




	def __init__( self						:		List[Any]		, _SCREAMING_SNAKE_CASE						:		Any=0		)->	Optional[Any]:  # a graph with Node 0,1,...,N-1
			lowerCAmelCase__       :      Optional[int]   					= n
			lowerCAmelCase__       :      List[Any]   					= [
			    [math.inf for j in range(0		, _SCREAMING_SNAKE_CASE		)] for i in range(0		, _SCREAMING_SNAKE_CASE		)
			]  # adjacency matrix for weight
			lowerCAmelCase__       :      str   					= [
			    [math.inf for j in range(0		, _SCREAMING_SNAKE_CASE		)] for i in range(0		, _SCREAMING_SNAKE_CASE		)
			]  # dp[i][j] stores minimum distance from i to j




	def 							UpperCAmelCase__( self						:		Optional[Any]		, _SCREAMING_SNAKE_CASE						:		Optional[int]		, _SCREAMING_SNAKE_CASE						:		List[str]		, _SCREAMING_SNAKE_CASE						:		str		)->	List[str]:
			lowerCAmelCase__       :      Optional[int]   					= w




	def 							UpperCAmelCase__( self						:		List[Any]		)->	Optional[int]:
			for k in range(0		, self.n		):
					for i in range(0		, self.n		):
							for j in range(0		, self.n		):
									lowerCAmelCase__       :      Dict   					= min(self.dp[i][j]		, self.dp[i][k] + self.dp[k][j]		)




	def 							UpperCAmelCase__( self						:		str		, _SCREAMING_SNAKE_CASE						:		Any		, _SCREAMING_SNAKE_CASE						:		str		)->	str:
			return self.dp[u][v]


if __name__ == "__main__":
		lowerCamelCase						=		Graph(5)
		graph.add_edge(0, 2, 9)
		graph.add_edge(0, 4, 10)
		graph.add_edge(1, 3, 5)
		graph.add_edge(2, 3, 7)
		graph.add_edge(3, 0, 10)
		graph.add_edge(3, 1, 2)
		graph.add_edge(3, 2, 1)
		graph.add_edge(3, 4, 6)
		graph.add_edge(4, 1, 3)
		graph.add_edge(4, 2, 4)
		graph.add_edge(4, 3, 9)
		graph.floyd_warshall()
		graph.show_min(1, 4)
		graph.show_min(0, 3)




