




from ..utils import DummyObject, requires_backends
class 			a__    (					metaclass=snake_case__      ):
						_a							:    Tuple					=    ["""onnx"""]






						def __init__(   self		,			*_A		,			**_A			):




											"""simple docstring"""



											requires_backends(self		,			["onnx"]			)






						@classmethod
						def 				__SCREAMING_SNAKE_CASE(   cls		,			*_A		,			**_A			):




											"""simple docstring"""



											requires_backends(cls		,			["onnx"]			)






						@classmethod
						def 				__SCREAMING_SNAKE_CASE(   cls		,			*_A		,			**_A			):




											"""simple docstring"""



											requires_backends(cls		,			["onnx"]			)










from queue import PriorityQueue
from typing import Any

import numpy as np







def 	_a      (						SCREAMING_SNAKE_CASE_							:				dict      ,      SCREAMING_SNAKE_CASE_							:				str      ,      SCREAMING_SNAKE_CASE_							:				set      ,      SCREAMING_SNAKE_CASE_							:				set      ,      SCREAMING_SNAKE_CASE_							:				dict      ,      SCREAMING_SNAKE_CASE_							:				dict      ,      SCREAMING_SNAKE_CASE_							:				PriorityQueue      ,      SCREAMING_SNAKE_CASE_							:				dict      ,      SCREAMING_SNAKE_CASE_							:				float | int      ,      ):
					for nxt, d in graph[v]:
										if nxt in visited_forward:
															continue
										__lowerCAmelCase				   =       cst_fwd.get(SCREAMING_SNAKE_CASE_      ,      np.inf     )
										__lowerCAmelCase				   =       cst_fwd[v] + d
										if new_cost_f < old_cost_f:
															queue.put((new_cost_f, nxt)     )
															__lowerCAmelCase				   =       new_cost_f
															__lowerCAmelCase				   =       v
										if nxt in visited_backward:
															if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
																				__lowerCAmelCase				   =       cst_fwd[v] + d + cst_bwd[nxt]
					return shortest_distance







def 	_a      (						SCREAMING_SNAKE_CASE_							:				str      ,      SCREAMING_SNAKE_CASE_							:				str      ,      SCREAMING_SNAKE_CASE_							:				dict      ,      SCREAMING_SNAKE_CASE_							:				dict     ):
					__lowerCAmelCase				   =       -1

					__lowerCAmelCase				   =       set()
					__lowerCAmelCase				   =       set()
					__lowerCAmelCase				   =       {source: 0}
					__lowerCAmelCase				   =       {destination: 0}
					__lowerCAmelCase				   =       {source: None}
					__lowerCAmelCase				   =       {destination: None}
					__lowerCAmelCase				   =       PriorityQueue()
					__lowerCAmelCase				   =       PriorityQueue()

					__lowerCAmelCase				   =       np.inf

					queue_forward.put((0, source)     )
					queue_backward.put((0, destination)     )

					if source == destination:
										return 0

					while not queue_forward.empty() and not queue_backward.empty():
										__lowerCAmelCase   ,							__lowerCAmelCase				   =       queue_forward.get()
										visited_forward.add(SCREAMING_SNAKE_CASE_     )

										__lowerCAmelCase   ,							__lowerCAmelCase				   =       queue_backward.get()
										visited_backward.add(SCREAMING_SNAKE_CASE_     )

										__lowerCAmelCase				   =       pass_and_relaxation(
										    SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      )

										__lowerCAmelCase				   =       pass_and_relaxation(
										    SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      SCREAMING_SNAKE_CASE_      ,      )

										if cst_fwd[v_fwd] + cst_bwd[v_bwd] >= shortest_distance:
															break

					if shortest_distance != np.inf:
										__lowerCAmelCase				   =       shortest_distance
					return shortest_path_distance


UpperCamelCase__    			=			{
    """B""": [["""C""", 1]],
    """C""": [["""D""", 1]],
    """D""": [["""F""", 1]],
    """E""": [["""B""", 1], ["""G""", 2]],
    """F""": [],
    """G""": [["""F""", 1]],
}
UpperCamelCase__    			=			{
    """B""": [["""E""", 1]],
    """C""": [["""B""", 1]],
    """D""": [["""C""", 1]],
    """F""": [["""D""", 1], ["""G""", 1]],
    """E""": [[None, np.inf]],
    """G""": [["""E""", 2]],
}

if __name__ == "__main__":
					import doctest

					doctest.testmod()




