Minimum Spanning Tree Kruskal

Given a connected, undirected graph with n vertices numbered 0 through n - 1 and a list of weighted edges, return the minimum total weight of a set of edges that connects every vertex without forming a cycle. Use Kruskal's algorithm: sort the edges by weight and accept an edge whenever its endpoints are still in different components, stopping once n - 1 edges have been accepted.

Examples
Input: [4,[[0,1,1],[1,2,2],[2,3,3],[3,0,4]]]
Output: 6
Hints

Minimum Spanning Tree Kruskal

Given a connected, undirected graph with `n` vertices numbered `0` through `n - 1` and a list of weighted edges, return the minimum total weight of a set of edges that connects every vertex without forming a cycle. Use Kruskal's algorithm: sort the edges by weight and accept an edge whenever its endpoints are still in different components, stopping once `n - 1` edges have been accepted.