Skip to content

Commit 3f2fa29

Browse files
authored
fix: remove redundant init step for unionFind (#709)
1 parent 6d83902 commit 3f2fa29

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

graph/kruskal.go

-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ func KruskalMST(n int, edges []Edge) ([]Edge, int) {
2828
// Create a new UnionFind data structure with 'n' nodes
2929
u := NewUnionFind(n)
3030

31-
// Initialize each node in the UnionFind data structure
32-
for i := 0; i < n; i++ {
33-
u.parent[i] = i
34-
u.size[i] = 1
35-
}
36-
3731
// Sort the edges in non-decreasing order based on their weights
3832
sort.SliceStable(edges, func(i, j int) bool {
3933
return edges[i].Weight < edges[j].Weight

0 commit comments

Comments
 (0)