

"""simple docstring"""





import inspect
import unittest




class 					_lowerCAmelCase  (	unittest.TestCase   ):







 """simple docstring"""







 def 					_lowercase (			self							:			Tuple	):
    try:
       import diffusers  # noqa: F401
    except ImportError:
       assert False



 def 					_lowercase (			self							:			Optional[Any]	):
    import diffusers
    from diffusers.dependency_versions_table import deps

    __lowercase								=						inspect.getmembers(UpperCAmelCase__,					inspect.isclass	)

    for cls_name, cls_module in all_classes:
       if "dummy_" in cls_module.__module__:
          for backend in cls_module._backends:
             if backend == "k_diffusion":
                __lowercase								=						"k-diffusion"
             elif backend == "invisible_watermark":
                __lowercase								=						"invisible-watermark"
             assert backend in deps, F"""{backend} is not in the deps table!"""








import heapq as hq
import math
from collections.abc import Iterator







class       lowerCamelCase__   :





     def __init__(self		,     UpperCAmelCase       )     ->   Any:
      _lowercase							      =str(id_       )
      _lowercase							      =None
      _lowercase							      =None
      _lowercase							      =[]
      _lowercase							      ={}  # {vertex:distance}





     def __lt__(self		,     UpperCAmelCase       )     ->   List[str]:
      return self.key < other.key





     def __repr__(self       )     ->   str:
      return self.id





     def      __A					(self		,     UpperCAmelCase       )     ->   Dict:
      self.neighbors.append(UpperCAmelCase       )





     def      __A					(self		,     UpperCAmelCase		,     UpperCAmelCase       )     ->   Optional[Any]:
      _lowercase							      =weight



def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case     ,						__snake_case     ,						__snake_case						)     ->			List[str]:







 """simple docstring"""


 graph[a - 1].add_neighbor(graph[b - 1]						)
 graph[b - 1].add_neighbor(graph[a - 1]						)
 # add the edges:
 graph[a - 1].add_edge(graph[b - 1]     ,						__snake_case						)
 graph[b - 1].add_edge(graph[a - 1]     ,						__snake_case						)
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			list:







 """simple docstring"""


 _lowercase							      =[]
 for u in graph:
  _lowercase							      =math.inf
  _lowercase							      =None
 _lowercase							      =0
 _lowercase							      =graph[:]
 while q:
  _lowercase							      =min(__snake_case						)
  q.remove(__snake_case						)
  for v in u.neighbors:
   if (v in q) and (u.edges[v.id] < v.key):
    _lowercase							      =u
    _lowercase							      =u.edges[v.id]
 for i in range(1     ,						len(__snake_case						)						):
  a.append((int(graph[i].id						) + 1, int(graph[i].pi.id						) + 1)						)
 return a
def 				UpperCAmelCase_					(							__snake_case     ,						__snake_case						)     ->			Iterator[tuple]:







 """simple docstring"""


 for u in graph:
  _lowercase							      =math.inf
  _lowercase							      =None
 _lowercase							      =0

 _lowercase							      =list(__snake_case						)
 hq.heapify(__snake_case						)

 while h:
  _lowercase							      =hq.heappop(__snake_case						)
  for v in u.neighbors:
   if (v in h) and (u.edges[v.id] < v.key):
    _lowercase							      =u
    _lowercase							      =u.edges[v.id]
    hq.heapify(__snake_case						)

 for i in range(1     ,						len(__snake_case						)						):
  yield (int(graph[i].id						) + 1, int(graph[i].pi.id						) + 1)
def 				UpperCAmelCase_					(							)     ->			None:







 """simple docstring"""




if __name__ == "__main__":
  import doctest

  doctest.testmod()

