blob: af5a8ff9a4133b4ff2447494d64c3b772a3fa3f7 (
plain)
1
2
3
4
5
6
7
8
9
|
sort(edges.begin(), edges.end());
vector<edge> mst;
int cost = 0;
for (edge& e : edges) {
if (findSet(e.from) != findSet(e.to)) {
unionSets(e.from, e.to);
mst.push_back(e);
cost += e.cost;
}}
|