From da71184b04837d2bc934f9947b4c262da096f349 Mon Sep 17 00:00:00 2001 From: Hasanul Islam Date: Mon, 2 Aug 2021 18:40:48 +0600 Subject: [PATCH] Fix mypy errors at mst_kruskal (#4581) --- graphs/minimum_spanning_tree_kruskal.py | 15 +++++++-------- graphs/tests/test_min_spanning_tree_kruskal.py | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/graphs/minimum_spanning_tree_kruskal.py b/graphs/minimum_spanning_tree_kruskal.py index a51f97034..f21a87a7d 100644 --- a/graphs/minimum_spanning_tree_kruskal.py +++ b/graphs/minimum_spanning_tree_kruskal.py @@ -1,15 +1,14 @@ -from typing import List, Tuple - - -def kruskal(num_nodes: int, num_edges: int, edges: List[Tuple[int, int, int]]) -> int: +def kruskal( + num_nodes: int, edges: list[tuple[int, int, int]] +) -> list[tuple[int, int, int]]: """ - >>> kruskal(4, 3, [(0, 1, 3), (1, 2, 5), (2, 3, 1)]) + >>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1)]) [(2, 3, 1), (0, 1, 3), (1, 2, 5)] - >>> kruskal(4, 5, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2)]) + >>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2)]) [(2, 3, 1), (0, 2, 1), (0, 1, 3)] - >>> kruskal(4, 6, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2), + >>> kruskal(4, [(0, 1, 3), (1, 2, 5), (2, 3, 1), (0, 2, 1), (0, 3, 2), ... (2, 1, 1)]) [(2, 3, 1), (0, 2, 1), (2, 1, 1)] """ @@ -44,4 +43,4 @@ if __name__ == "__main__": # pragma: no cover node1, node2, cost = [int(x) for x in input().strip().split()] edges.append((node1, node2, cost)) - kruskal(num_nodes, num_edges, edges) + kruskal(num_nodes, edges) diff --git a/graphs/tests/test_min_spanning_tree_kruskal.py b/graphs/tests/test_min_spanning_tree_kruskal.py index 3a527aef3..d6df242ec 100644 --- a/graphs/tests/test_min_spanning_tree_kruskal.py +++ b/graphs/tests/test_min_spanning_tree_kruskal.py @@ -2,7 +2,7 @@ from graphs.minimum_spanning_tree_kruskal import kruskal def test_kruskal_successful_result(): - num_nodes, num_edges = 9, 14 + num_nodes = 9 edges = [ [0, 1, 4], [0, 7, 8], @@ -20,7 +20,7 @@ def test_kruskal_successful_result(): [1, 7, 11], ] - result = kruskal(num_nodes, num_edges, edges) + result = kruskal(num_nodes, edges) expected = [ [7, 6, 1],