No frills kruskal's algorithm implementation in javascript