[mypy] Fix type annotations for graphs/boruvka (#4867)

* fix: type annotations for pypi 🏷️

Fixes #4052

* updating DIRECTORY.md

* apply suggestions from code review

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Meysam 2021-10-17 19:26:12 +03:00 committed by GitHub
parent 4bf2eedd3c
commit 08d4d226d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@
Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm
"""
from __future__ import annotations
class Graph:
@ -39,8 +40,8 @@ class Graph:
"""
self.m_num_of_nodes = num_of_nodes
self.m_edges = []
self.m_component = {}
self.m_edges: list[list[int]] = []
self.m_component: dict[int, int] = {}
def add_edge(self, u_node: int, v_node: int, weight: int) -> None:
"""Adds an edge in the format [first, second, edge weight] to graph."""
@ -83,7 +84,7 @@ class Graph:
component_size = []
mst_weight = 0
minimum_weight_edge = [-1] * self.m_num_of_nodes
minimum_weight_edge: list[int] = [-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):