mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 01:00:15 +00:00
[mypy] Fix type annotations in graphs/boruvka.py
(#5794)
* Fix type annotations in boruvka.py * Remove graphs/boruvka.py| * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
2f6a7ae1fa
commit
ac4bdfd66d
|
@ -109,8 +109,10 @@
|
||||||
|
|
||||||
## Computer Vision
|
## Computer Vision
|
||||||
* [Cnn Classification](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/cnn_classification.py)
|
* [Cnn Classification](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/cnn_classification.py)
|
||||||
|
* [Flip Augmentation](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/flip_augmentation.py)
|
||||||
* [Harris Corner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harris_corner.py)
|
* [Harris Corner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harris_corner.py)
|
||||||
* [Mean Threshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mean_threshold.py)
|
* [Mean Threshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mean_threshold.py)
|
||||||
|
* [Mosaic Augmentation](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mosaic_augmentation.py)
|
||||||
|
|
||||||
## Conversions
|
## Conversions
|
||||||
* [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py)
|
* [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py)
|
||||||
|
@ -297,8 +299,8 @@
|
||||||
* [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py)
|
* [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py)
|
||||||
|
|
||||||
## Financial
|
## Financial
|
||||||
|
* [Equated Monthly Installments](https://github.com/TheAlgorithms/Python/blob/master/financial/equated_monthly_installments.py)
|
||||||
* [Interest](https://github.com/TheAlgorithms/Python/blob/master/financial/interest.py)
|
* [Interest](https://github.com/TheAlgorithms/Python/blob/master/financial/interest.py)
|
||||||
* [EMI Calculation](https://github.com/TheAlgorithms/Python/blob/master/financial/equated_monthly_installments.py)
|
|
||||||
|
|
||||||
## Fractals
|
## Fractals
|
||||||
* [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py)
|
* [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py)
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
class Graph:
|
class Graph:
|
||||||
def __init__(self, num_of_nodes: int) -> None:
|
def __init__(self, num_of_nodes: int) -> None:
|
||||||
|
@ -62,7 +64,7 @@ class Graph:
|
||||||
for k in self.m_component:
|
for k in self.m_component:
|
||||||
self.m_component[k] = self.find_component(k)
|
self.m_component[k] = self.find_component(k)
|
||||||
|
|
||||||
def union(self, component_size: list, u_node: int, v_node: int) -> None:
|
def union(self, component_size: list[int], u_node: int, v_node: int) -> None:
|
||||||
"""Union finds the roots of components for two nodes, compares the components
|
"""Union finds the roots of components for two nodes, compares the components
|
||||||
in terms of size, and attaches the smaller one to the larger one to form
|
in terms of size, and attaches the smaller one to the larger one to form
|
||||||
single component"""
|
single component"""
|
||||||
|
@ -84,7 +86,7 @@ class Graph:
|
||||||
component_size = []
|
component_size = []
|
||||||
mst_weight = 0
|
mst_weight = 0
|
||||||
|
|
||||||
minimum_weight_edge: list[int] = [-1] * self.m_num_of_nodes
|
minimum_weight_edge: list[Any] = [-1] * self.m_num_of_nodes
|
||||||
|
|
||||||
# A list of components (initialized to all of the nodes)
|
# A list of components (initialized to all of the nodes)
|
||||||
for node in range(self.m_num_of_nodes):
|
for node in range(self.m_num_of_nodes):
|
||||||
|
@ -119,7 +121,7 @@ class Graph:
|
||||||
minimum_weight_edge[component] = [u, v, w]
|
minimum_weight_edge[component] = [u, v, w]
|
||||||
|
|
||||||
for edge in minimum_weight_edge:
|
for edge in minimum_weight_edge:
|
||||||
if edge != -1:
|
if isinstance(edge, list):
|
||||||
u, v, w = edge
|
u, v, w = edge
|
||||||
|
|
||||||
u_component = self.m_component[u]
|
u_component = self.m_component[u]
|
||||||
|
|
2
mypy.ini
2
mypy.ini
|
@ -2,4 +2,4 @@
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
install_types = True
|
install_types = True
|
||||||
non_interactive = True
|
non_interactive = True
|
||||||
exclude = (graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)
|
exclude = (graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user