MST: algorithm of Kruskal

Enter the adjacency list of your graph. Each line must start with a vertex label. The other tokens in the line for a vertex u describe the adjacency list of u. They must come in pairs v w, where (u,v) is an edge and w is its weight. Separate all tokens with space(s).

In the example below, the vertex a is adjacent with vertices b and h, and the edge weights of (a,b) and (a,h) are 4 and 8, respectively.

The maximum input length is limited by 300 characters including spaces.

Program output

Source code