


'''simple docstring'''



from __future__ import annotations




def 			_a			(		_lowercase      :			list[float]    ,      _lowercase      :			Union[str, Any]						):





     '''simple docstring'''






     print(F'Vertex\tShortest Distance from vertex {src}'						)
     for i, d in enumerate(_lowercase						):
          print(F'{i}\t\t{d}'						)




def 			_a			(		_lowercase      :			list[dict[str, int]]    ,      _lowercase      :			list[float]    ,      _lowercase      :			int						):





     '''simple docstring'''






     for j in range(_lowercase						):
          __UpperCAmelCase							,     __UpperCAmelCase							,     __UpperCAmelCase			:				Optional[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 			_a			(		_lowercase      :			list[dict[str, int]]    ,      _lowercase      :			int    ,      _lowercase      :			int    ,      _lowercase      :			int						):





     '''simple docstring'''






     __UpperCAmelCase			:				Optional[Any]													=    [float('''inf'''						)] * vertex_count
     __UpperCAmelCase			:				List[Any]													=    0.0

     for _ in range(vertex_count - 1						):
          for j in range(_lowercase						):
               __UpperCAmelCase							,     __UpperCAmelCase							,     __UpperCAmelCase			:				List[str]													=    (graph[j][k] for k in ['''src''', '''dst''', '''weight'''])

               if distance[u] != float('''inf'''						) and distance[u] + w < distance[v]:
                    __UpperCAmelCase			:				Optional[Any]													=    distance[u] + w

     __UpperCAmelCase			:				Dict													=    check_negative_cycle(_lowercase    ,      _lowercase    ,      _lowercase						)
     if negative_cycle_exists:
          raise Exception('''Negative cycle found'''						)

     return distance


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      __UpperCAmelCase    :Optional[int]				       =     int(input("Enter number of vertices: ").strip())
      __UpperCAmelCase    :Dict				       =     int(input("Enter number of edges: ").strip())

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

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

      __UpperCAmelCase    :Any				       =     int(input("\nEnter shortest path source:").strip())
      __UpperCAmelCase    :List[Any]				       =     bellman_ford(graph, V, E, source)
      print_distance(shortest_distance, 0)



'''simple docstring'''



from itertools import product

from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros




def 			_a			(		_lowercase      :			Optional[Any]    ,      _lowercase      :			List[Any]						):





     '''simple docstring'''






     __UpperCAmelCase			:				Dict													=    k_size // 2
     __UpperCAmelCase							,     __UpperCAmelCase			:				Any													=    mgrid[0 - center : k_size - center, 0 - center : k_size - center]
     __UpperCAmelCase			:				Optional[int]													=    1 / (2 * pi * sigma) * exp(-(square(_lowercase						) + square(_lowercase						)) / (2 * square(_lowercase						))						)
     return g




def 			_a			(		_lowercase      :			str    ,      _lowercase      :			List[str]    ,      _lowercase      :			Optional[Any]						):





     '''simple docstring'''






     __UpperCAmelCase							,     __UpperCAmelCase			:				Any													=    image.shape[0], image.shape[1]
     # dst image height and width
     __UpperCAmelCase			:				Any													=    height - k_size + 1
     __UpperCAmelCase			:				str													=    width - k_size + 1

     # im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
     __UpperCAmelCase			:				Optional[int]													=    zeros((dst_height * dst_width, k_size * k_size)						)
     __UpperCAmelCase			:				Optional[Any]													=    0
     for i, j in product(range(_lowercase						)    ,      range(_lowercase						)						):
          __UpperCAmelCase			:				List[Any]													=    ravel(image[i : i + k_size, j : j + k_size]						)
          __UpperCAmelCase			:				Optional[int]													=    window
          row += 1

     #  turn the kernel into shape(k*k, 1)
     __UpperCAmelCase			:				str													=    gen_gaussian_kernel(_lowercase    ,      _lowercase						)
     __UpperCAmelCase			:				Union[str, Any]													=    ravel(_lowercase						)

     # reshape and get the dst image
     __UpperCAmelCase			:				Optional[int]													=    dot(_lowercase    ,      _lowercase						).reshape(_lowercase    ,      _lowercase						).astype(_lowercase						)

     return dst


if __name__ == "__main__":
      # read original image
      __UpperCAmelCase    :Dict				       =     imread(r"../image_data/lena.jpg")
      # turn image in gray scale value
      __UpperCAmelCase    :Tuple				       =     cvtColor(img, COLOR_BGR2GRAY)

      # get values with two different mask size
      __UpperCAmelCase    :Tuple				       =     gaussian_filter(gray, 3, sigma=1)
      __UpperCAmelCase    :Optional[Any]				       =     gaussian_filter(gray, 5, sigma=0.8)

      # show result images
      imshow("gaussian filter with 3x3 mask", gaussianaxa)
      imshow("gaussian filter with 5x5 mask", gaussianaxa)
      waitKey()