




from __future__ import annotations

import os
from collections.abc import Mapping

_lowerCamelCase      :  Union[str, Any]      						=						tuple[int, int]
class        __snake_case  :



				def __init__(      self      :		str		,	_UpperCAmelCase      :		Dict		,	_UpperCAmelCase      :		str      )  ->    int:





								'''simple docstring'''




								_lowerCAmelCase										=      vertices
								_lowerCAmelCase										=      {
								    (min(snake_case__      ), max(snake_case__      )): weight for edge, weight in edges.items()
								}



				def       SCREAMING_SNAKE_CASE       (      self      :		int		,	_UpperCAmelCase      :		Dict		,	_UpperCAmelCase      :		Optional[int]      )  ->    Dict:





								'''simple docstring'''




								self.vertices.add(edge[0]      )
								self.vertices.add(edge[1]      )
								_lowerCAmelCase										=      weight



				def       SCREAMING_SNAKE_CASE       (      self      :		Tuple      )  ->    List[str]:





								'''simple docstring'''




								_lowerCAmelCase										=      Graph({min(self.vertices      )}		,	{}      )
								_lowerCAmelCase										=      42
								_lowerCAmelCase										=      42
								_lowerCAmelCase										=      42
								_lowerCAmelCase										=      42

								while len(subgraph.vertices      ) < len(self.vertices      ):
												_lowerCAmelCase										=      max(self.edges.values()      ) + 1
												for edge, weight in self.edges.items():
																if (edge[0] in subgraph.vertices) ^ (edge[1] in subgraph.vertices):
																				if weight < min_weight:
																								_lowerCAmelCase										=      edge
																								_lowerCAmelCase										=      weight

												subgraph.add_edge(snake_case__		,	snake_case__      )

								return subgraph






def 							_UpperCAmelCase  (UpperCamelCase_ : Optional[Any] = "p107_network.txt"       ):
				'''simple docstring'''
				_lowerCAmelCase										=      os.path.abspath(os.path.dirname(UpperCamelCase_       )       )
				_lowerCAmelCase										=      os.path.join(UpperCamelCase_      ,    UpperCamelCase_       )
				_lowerCAmelCase										=      {}
				_lowerCAmelCase										=      42
				_lowerCAmelCase										=      42
				_lowerCAmelCase										=      42

				with open(UpperCamelCase_       ) as f:
								_lowerCAmelCase										=      f.read().strip().split("""\n"""       )

				_lowerCAmelCase										=      [line.split(""","""       ) for line in data]

				for edgea in range(1      ,    len(UpperCamelCase_       )       ):
								for edgea in range(UpperCamelCase_       ):
												if adjaceny_matrix[edgea][edgea] != "-":
																_lowerCAmelCase										=      int(adjaceny_matrix[edgea][edgea]       )

				_lowerCAmelCase										=      Graph(set(range(len(UpperCamelCase_       )       )       )      ,    UpperCamelCase_       )

				_lowerCAmelCase										=      graph.prims_algorithm()

				_lowerCAmelCase										=      sum(graph.edges.values()       )
				_lowerCAmelCase										=      sum(subgraph.edges.values()       )

				return initial_total - optimal_total


if __name__ == "__main__":
	print(F'''{solution() = }''')







import numpy as np




def 							_UpperCAmelCase  (UpperCamelCase_ : np.array       ):
				'''simple docstring'''
				return (2 / (1 + np.exp(-2 * vector       ))) - 1


if __name__ == "__main__":
	import doctest

	doctest.testmod()

