"""simple docstring"""





from __future__ import annotations

from typing import Any
class  _snake_case     :






      def __init__(       self      :			int							,					UpperCAmelCase      :			int    ):
             __lowerCamelCase					:		List[Any]		   =     num_of_nodes
             __lowerCamelCase					:		list[list[int]]		   =     []
             __lowerCamelCase					:		dict[int, int]		   =     {}






      def       lowerCamelCase__     (       self      :			Any							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			int    ):
             self.m_edges.append([u_node, v_node, weight]    )






      def       lowerCamelCase__     (       self      :			int							,					UpperCAmelCase      :			int    ):

             if self.m_component[u_node] == u_node:
                    return u_node
             return self.find_component(self.m_component[u_node]    )






      def       lowerCamelCase__     (       self      :			Union[str, Any]							,					UpperCAmelCase      :			int    ):

             if self.m_component[u_node] != u_node:
                    for k in self.m_component:
                           __lowerCamelCase					:		int		   =     self.find_component(UpperCAmelCase    )






      def       lowerCamelCase__     (       self      :			int							,					UpperCAmelCase      :			list[int]							,					UpperCAmelCase      :			int							,					UpperCAmelCase      :			int    ):

             if component_size[u_node] <= component_size[v_node]:
                    __lowerCamelCase					:		Optional[int]		   =     v_node
                    component_size[v_node] += component_size[u_node]
                    self.set_component(UpperCAmelCase    )

             elif component_size[u_node] >= component_size[v_node]:
                    __lowerCamelCase					:		Optional[int]		   =     self.find_component(UpperCAmelCase    )
                    component_size[u_node] += component_size[v_node]
                    self.set_component(UpperCAmelCase    )







      def       lowerCamelCase__     (       self      :			List[str]    ):
             __lowerCamelCase					:		List[Any]		   =     []
             __lowerCamelCase					:		Tuple		   =     0

             __lowerCamelCase					:		list[Any]		   =     [-1] * self.m_num_of_nodes

             # A list of components (initialized to all of the nodes)
             for node in range(self.m_num_of_nodes    ):
                    self.m_component.update({node: node}    )
                    component_size.append(1    )

             __lowerCamelCase					:		int		   =     self.m_num_of_nodes

             while num_of_components > 1:
                    for edge in self.m_edges:
                           __lowerCamelCase					:		List[str]		   =     edge

                           __lowerCamelCase					:		Optional[int]		   =     self.m_component[u]
                           __lowerCamelCase					:		Union[str, Any]		   =     self.m_component[v]

                           if u_component != v_component:

                                  for component in (u_component, v_component):
                                         if (
                                             minimum_weight_edge[component] == -1
                                             or minimum_weight_edge[component][2] > w
                                         ):
                                                __lowerCamelCase					:		Dict		   =     [u, v, w]

                    for edge in minimum_weight_edge:
                           if isinstance(UpperCAmelCase							,					UpperCAmelCase    ):
                                  __lowerCamelCase					:		Dict		   =     edge

                                  __lowerCamelCase					:		str		   =     self.m_component[u]
                                  __lowerCamelCase					:		Dict		   =     self.m_component[v]

                                  if u_component != v_component:
                                         mst_weight += w
                                         self.union(UpperCAmelCase							,					UpperCAmelCase							,					UpperCAmelCase    )
                                         print(F"""Added edge [{u} - {v}]\nAdded weight: {w}\n"""    )
                                         num_of_components -= 1

                    __lowerCamelCase					:		Any		   =     [-1] * self.m_num_of_nodes
             print(F"""The total weight of the minimal spanning tree is: {mst_weight}"""    )


def    lowercase_   (   ) ->      None:



       '''simple docstring'''




if __name__ == "__main__":
    import doctest

    doctest.testmod()
"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tensorflow_text_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A  =				{
    '''configuration_bert''': ['''BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BertConfig''', '''BertOnnxConfig'''],
    '''tokenization_bert''': ['''BasicTokenizer''', '''BertTokenizer''', '''WordpieceTokenizer'''],
}

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A  =				['''BertTokenizerFast''']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A  =				[
				    '''BERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
				    '''BertForMaskedLM''',
				    '''BertForMultipleChoice''',
				    '''BertForNextSentencePrediction''',
				    '''BertForPreTraining''',
				    '''BertForQuestionAnswering''',
				    '''BertForSequenceClassification''',
				    '''BertForTokenClassification''',
				    '''BertLayer''',
				    '''BertLMHeadModel''',
				    '''BertModel''',
				    '''BertPreTrainedModel''',
				    '''load_tf_weights_in_bert''',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A  =				[
				    '''TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
				    '''TFBertEmbeddings''',
				    '''TFBertForMaskedLM''',
				    '''TFBertForMultipleChoice''',
				    '''TFBertForNextSentencePrediction''',
				    '''TFBertForPreTraining''',
				    '''TFBertForQuestionAnswering''',
				    '''TFBertForSequenceClassification''',
				    '''TFBertForTokenClassification''',
				    '''TFBertLMHeadModel''',
				    '''TFBertMainLayer''',
				    '''TFBertModel''',
				    '''TFBertPreTrainedModel''',
				]
try:
				if not is_tensorflow_text_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A  =				['''TFBertTokenizer''']

try:
				if not is_flax_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__A  =				[
				    '''FlaxBertForCausalLM''',
				    '''FlaxBertForMaskedLM''',
				    '''FlaxBertForMultipleChoice''',
				    '''FlaxBertForNextSentencePrediction''',
				    '''FlaxBertForPreTraining''',
				    '''FlaxBertForQuestionAnswering''',
				    '''FlaxBertForSequenceClassification''',
				    '''FlaxBertForTokenClassification''',
				    '''FlaxBertModel''',
				    '''FlaxBertPreTrainedModel''',
				]

if TYPE_CHECKING:
				from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig, BertOnnxConfig
				from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_bert_fast import BertTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_bert import (
								    BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    BertForMaskedLM,
								    BertForMultipleChoice,
								    BertForNextSentencePrediction,
								    BertForPreTraining,
								    BertForQuestionAnswering,
								    BertForSequenceClassification,
								    BertForTokenClassification,
								    BertLayer,
								    BertLMHeadModel,
								    BertModel,
								    BertPreTrainedModel,
								    load_tf_weights_in_bert,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_bert import (
								    TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFBertEmbeddings,
								    TFBertForMaskedLM,
								    TFBertForMultipleChoice,
								    TFBertForNextSentencePrediction,
								    TFBertForPreTraining,
								    TFBertForQuestionAnswering,
								    TFBertForSequenceClassification,
								    TFBertForTokenClassification,
								    TFBertLMHeadModel,
								    TFBertMainLayer,
								    TFBertModel,
								    TFBertPreTrainedModel,
								)

				try:
								if not is_tensorflow_text_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_bert_tf import TFBertTokenizer

				try:
								if not is_flax_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_flax_bert import (
								    FlaxBertForCausalLM,
								    FlaxBertForMaskedLM,
								    FlaxBertForMultipleChoice,
								    FlaxBertForNextSentencePrediction,
								    FlaxBertForPreTraining,
								    FlaxBertForQuestionAnswering,
								    FlaxBertForSequenceClassification,
								    FlaxBertForTokenClassification,
								    FlaxBertModel,
								    FlaxBertPreTrainedModel,
								)

else:
				import sys

				__A  =				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)