Implement kruskal's algorithm and test it