




from __future__ import annotations

import os
from collections.abc import Mapping

UpperCamelCase__     =	tuple[int, int]

class     __SCREAMING_SNAKE_CASE   :






							def __init__(  self					,	__lowerCAmelCase					,	__lowerCAmelCase					):
														UpperCamelCase__			       =     vertices
														UpperCamelCase__			       =     {
														    (min(__lowerCAmelCase					), max(__lowerCAmelCase					)): weight for edge, weight in edges.items()
														}






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase					):
														self.vertices.add(edge[0]					)
														self.vertices.add(edge[1]					)
														UpperCamelCase__			       =     weight







							def 			_lowerCamelCase						(  self					):
														UpperCamelCase__			       =     Graph({min(self.vertices					)}					,	{}					)
														UpperCamelCase__			       =     42
														UpperCamelCase__			       =     42
														UpperCamelCase__			       =     42
														UpperCamelCase__			       =     42

														while len(subgraph.vertices					) < len(self.vertices					):
																					UpperCamelCase__			       =     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:
																																										UpperCamelCase__			       =     edge
																																										UpperCamelCase__			       =     weight

																					subgraph.add_edge(__lowerCAmelCase					,	__lowerCAmelCase					)

														return subgraph






def       _UpperCamelCase       (a__				:str = "p107_network.txt"    ):






							"""simple docstring"""





							UpperCamelCase__			       =     os.path.abspath(os.path.dirname(UpperCAmelCase_    )    )
							UpperCamelCase__			       =     os.path.join(UpperCAmelCase_				,     UpperCAmelCase_    )
							UpperCamelCase__			       =     {}
							UpperCamelCase__			       =     42
							UpperCamelCase__			       =     42
							UpperCamelCase__			       =     42

							with open(UpperCAmelCase_    ) as f:
														UpperCamelCase__			       =     f.read().strip().split("""\n"""    )

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

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

							UpperCamelCase__			       =     Graph(set(range(len(UpperCAmelCase_    )    )    )				,     UpperCAmelCase_    )

							UpperCamelCase__			       =     graph.prims_algorithm()

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

							return initial_total - optimal_total


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











UpperCamelCase__     =	{
    "meter": "m",
    "kilometer": "km",
    "megametre": "Mm",
    "gigametre": "Gm",
    "terametre": "Tm",
    "petametre": "Pm",
    "exametre": "Em",
    "zettametre": "Zm",
    "yottametre": "Ym",
}
# Exponent of the factor(meter)
UpperCamelCase__     =	{
    "m": 0,
    "km": 3,
    "Mm": 6,
    "Gm": 9,
    "Tm": 12,
    "Pm": 15,
    "Em": 18,
    "Zm": 21,
    "Ym": 24,
}





def       _UpperCamelCase       (a__				:float				,     a__				:str				,     a__				:str    ):






							"""simple docstring"""





							UpperCamelCase__			       =     from_type.lower().strip("""s"""    )
							UpperCamelCase__			       =     to_type.lower().strip("""s"""    )

							UpperCamelCase__			       =     UNIT_SYMBOL.get(a__				,     a__    )
							UpperCamelCase__			       =     UNIT_SYMBOL.get(a__				,     a__    )

							if from_sanitized not in METRIC_CONVERSION:
														UpperCamelCase__			       =     (
														    f"""Invalid 'from_type' value: {from_type!r}.\n"""
														    f"""Conversion abbreviations are: {", ".join(a__    )}"""
														)
														raise ValueError(a__    )
							if to_sanitized not in METRIC_CONVERSION:
														UpperCamelCase__			       =     (
														    f"""Invalid 'to_type' value: {to_type!r}.\n"""
														    f"""Conversion abbreviations are: {", ".join(a__    )}"""
														)
														raise ValueError(a__    )
							UpperCamelCase__			       =     METRIC_CONVERSION[from_sanitized]
							UpperCamelCase__			       =     METRIC_CONVERSION[to_sanitized]
							UpperCamelCase__			       =     1

							if from_exponent > to_exponent:
														UpperCamelCase__			       =     from_exponent - to_exponent
							else:
														UpperCamelCase__			       =     -(to_exponent - from_exponent)

							return value * pow(10				,     a__    )


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

					testmod()




