Takes a list of node pairs and their weights separated by new lines and links them up and says the weight of the tree based on the Kruskal algorithm