


'''simple docstring'''

import math
class   __lowerCAmelCase						:





      '''simple docstring'''






      def __init__(self    :    str   ,						UpperCamelCase    :    List[Any]=0 ):  # a graph with Node 0,1,...,N-1

             '''simple docstring'''







             lowercase__      			= n
             lowercase__      			= [
                 [math.inf for j in range(0   ,						UpperCamelCase )] for i in range(0   ,						UpperCamelCase )
             ]  # adjacency matrix for weight
             lowercase__      			= [
                 [math.inf for j in range(0   ,						UpperCamelCase )] for i in range(0   ,						UpperCamelCase )
             ]  # dp[i][j] stores minimum distance from i to j



      def       UpperCamelCase__		(self    :    Any   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    Optional[int]   ,						UpperCamelCase    :    List[Any] ):

             '''simple docstring'''







             lowercase__      			= w



      def       UpperCamelCase__		(self    :    Optional[int] ):

             '''simple docstring'''







             for k in range(0   ,						self.n ):
                    for i in range(0   ,						self.n ):
                           for j in range(0   ,						self.n ):
                                  lowercase__      			= min(self.dp[i][j]   ,						self.dp[i][k] + self.dp[k][j] )






      def       UpperCamelCase__		(self    :    Any   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    int ):

             '''simple docstring'''







             return self.dp[u][v]


if __name__ == "__main__":
 lowerCamelCase							:   Any  						=	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)








'''simple docstring'''

class   __lowerCAmelCase						:  # Public class to implement a graph





      '''simple docstring'''






      def __init__(self    :    int   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    list[list[bool]] ):

             '''simple docstring'''







             lowercase__      			= row
             lowercase__      			= col
             lowercase__      			= graph



      def       UpperCamelCase__		(self    :    Optional[int]   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    list[list[bool]] ):

             '''simple docstring'''







             return (
                 0 <= i < self.ROW
                 and 0 <= j < self.COL
                 and not visited[i][j]
                 and self.graph[i][j]
             )



      def       UpperCamelCase__		(self    :    int   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    int   ,						UpperCamelCase    :    list[list[bool]] ):

             '''simple docstring'''







             lowercase__      			= [-1, -1, -1, 0, 0, 1, 1, 1]  # Coordinate order
             lowercase__      			= [-1, 0, 1, -1, 1, -1, 0, 1]
             lowercase__      			= True  # Make those cells visited
             for k in range(8 ):
                    if self.is_safe(i + row_nbr[k]   ,						j + col_nbr[k]   ,						UpperCamelCase ):
                           self.diffs(i + row_nbr[k]   ,						j + col_nbr[k]   ,						UpperCamelCase )






      def       UpperCamelCase__		(self    :    Dict ):  # And finally, count all islands.

             '''simple docstring'''







             lowercase__      			= [[False for j in range(self.COL )] for i in range(self.ROW )]
             lowercase__      			= 0
             for i in range(self.ROW ):
                    for j in range(self.COL ):
                           if visited[i][j] is False and self.graph[i][j] == 1:
                                  self.diffs(UpperCamelCase   ,						UpperCamelCase   ,						UpperCamelCase )
                                  count += 1
             return count




