

'''simple docstring'''
import heapq as hq
import math
from collections.abc import Iterator







class 							A__   :





  def __init__(		self				:     int							, _a				:     Union[str, Any]			)     ->   Optional[Any]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							   =str(id_			)
       _SCREAMING_SNAKE_CASE							   =None
       _SCREAMING_SNAKE_CASE							   =None
       _SCREAMING_SNAKE_CASE							   =[]
       _SCREAMING_SNAKE_CASE							   ={}  # {vertex:distance}





  def __lt__(		self				:     int							, _a				:     Optional[Any]			)     ->   int:





       '''simple docstring'''






       return self.key < other.key





  def __repr__(		self				:     str			)     ->   List[Any]:





       '''simple docstring'''






       return self.id





  def 						A  (		self				:     List[str]							, _a				:     Optional[Any]			)     ->   Dict:





       '''simple docstring'''






       self.neighbors.append(_a			)





  def 						A  (		self				:     str							, _a				:     Any							, _a				:     Tuple			)     ->   Optional[Any]:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							   =weight


def 	_lowerCAmelCase (						_UpperCamelCase						:					Tuple							,			_UpperCamelCase						:					List[str]							,			_UpperCamelCase						:					Any							,			_UpperCamelCase						:					List[Any]    )				->      Optional[Any]:
     """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]							,			_UpperCamelCase    )
     graph[b - 1].add_edge(graph[a - 1]							,			_UpperCamelCase    )


def 	_lowerCAmelCase (						_UpperCamelCase						:					list							,			_UpperCamelCase						:					Vertex    )				->      list:
     """simple docstring"""




     _SCREAMING_SNAKE_CASE							   =[]
     for u in graph:
          _SCREAMING_SNAKE_CASE							   =math.inf
          _SCREAMING_SNAKE_CASE							   =None
     _SCREAMING_SNAKE_CASE							   =0
     _SCREAMING_SNAKE_CASE							   =graph[:]
     while q:
          _SCREAMING_SNAKE_CASE							   =min(_UpperCamelCase    )
          q.remove(_UpperCamelCase    )
          for v in u.neighbors:
               if (v in q) and (u.edges[v.id] < v.key):
                    _SCREAMING_SNAKE_CASE							   =u
                    _SCREAMING_SNAKE_CASE							   =u.edges[v.id]
     for i in range(1							,			len(_UpperCamelCase    )    ):
          a.append((int(graph[i].id    ) + 1, int(graph[i].pi.id    ) + 1)    )
     return a


def 	_lowerCAmelCase (						_UpperCamelCase						:					list							,			_UpperCamelCase						:					Vertex    )				->      Iterator[tuple]:
     """simple docstring"""




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

     _SCREAMING_SNAKE_CASE							   =list(_UpperCamelCase    )
     hq.heapify(_UpperCamelCase    )

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

     for i in range(1							,			len(_UpperCamelCase    )    ):
          yield (int(graph[i].id    ) + 1, int(graph[i].pi.id    ) + 1)


def 	_lowerCAmelCase (						)				->      None:
     """simple docstring"""










if __name__ == "__main__":
     import doctest

     doctest.testmod()



'''simple docstring'''
from math import factorial


def 	_lowerCAmelCase (						_UpperCamelCase						:					int							,			_UpperCamelCase						:					int							,			_UpperCamelCase						:					float    )				->      float:
     """simple docstring"""




     if successes > trials:
          raise ValueError('successes must be lower or equal to trials'    )
     if trials < 0 or successes < 0:
          raise ValueError('the function is defined for non-negative integers'    )
     if not isinstance(_UpperCamelCase							,			_UpperCamelCase    ) or not isinstance(_UpperCamelCase							,			_UpperCamelCase    ):
          raise ValueError('the function is defined for non-negative integers'    )
     if not 0 < prob < 1:
          raise ValueError('prob has to be in range of 1 - 0'    )
     _SCREAMING_SNAKE_CASE							   =(prob**successes) * ((1 - prob) ** (trials - successes))
     # Calculate the binomial coefficient: n! / k!(n-k)!
     _SCREAMING_SNAKE_CASE							   =float(factorial(_UpperCamelCase    )    )
     coefficient /= factorial(_UpperCamelCase    ) * factorial(trials - successes    )
     return probability * coefficient


if __name__ == "__main__":
     from doctest import testmod

     testmod()
     print("Probability of 2 successes out of 4 trails")
     print("with probability of 0.75 is:", end=" ")
     print(binomial_distribution(2, 4, 0.7_5))
