File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 24
24
25
25
Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm
26
26
"""
27
+ from __future__ import annotations
27
28
28
29
29
30
class Graph :
@@ -39,8 +40,8 @@ def __init__(self, num_of_nodes: int) -> None:
39
40
"""
40
41
41
42
self .m_num_of_nodes = num_of_nodes
42
- self .m_edges = []
43
- self .m_component = {}
43
+ self .m_edges : list [ list [ int ]] = []
44
+ self .m_component : dict [ int , int ] = {}
44
45
45
46
def add_edge (self , u_node : int , v_node : int , weight : int ) -> None :
46
47
"""Adds an edge in the format [first, second, edge weight] to graph."""
@@ -83,7 +84,7 @@ def boruvka(self) -> None:
83
84
component_size = []
84
85
mst_weight = 0
85
86
86
- minimum_weight_edge = [- 1 ] * self .m_num_of_nodes
87
+ minimum_weight_edge : list [ int ] = [- 1 ] * self .m_num_of_nodes
87
88
88
89
# A list of components (initialized to all of the nodes)
89
90
for node in range (self .m_num_of_nodes ):
You can’t perform that action at this time.
0 commit comments