mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Fix mypy errors at mst_kruskal (#4581)
This commit is contained in:
parent
a5bcf0f674
commit
da71184b04
|
@ -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)
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in New Issue
Block a user