Skip to content

Commit

Permalink
[mypy] Fix type annotations for graphs/boruvka (TheAlgorithms#4867)
Browse files Browse the repository at this point in the history
* fix: type annotations for pypi 🏷️

Fixes TheAlgorithms#4052

* updating DIRECTORY.md

* apply suggestions from code review

Co-authored-by: Christian Clauss <[email protected]>

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
3 people authored Oct 17, 2021
1 parent 4bf2eed commit 08d4d22
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions graphs/boruvka.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm
"""
from __future__ import annotations


class Graph:
Expand All @@ -39,8 +40,8 @@ def __init__(self, num_of_nodes: int) -> None:
"""

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."""
Expand Down Expand Up @@ -83,7 +84,7 @@ def boruvka(self) -> None:
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):
Expand Down

0 comments on commit 08d4d22

Please sign in to comment.