class union_find{ vector p,rank; public: union_find(int n):p(n),rank(n){ for(int x=0;x rank[y]) swap(x,y); if(rank[x]==rank[y]) rank[y]++; p[x]=y; } }; struct edge{ int u,v; double cost; bool operator<(const edge &e)const{ return cost Kruskal(int n,vector E){ // n = |V|, グラフは辺集合で与える vector M; sort(E.begin(),E.end()); union_find U(n); for(int i=0;i