Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sort(EdgeList.begin(), EdgeList.end());
- int mst_cost = 0;
- WQUPC uf(V);
- for (int i = 0; i < E; i++)
- {
- pair<int, ii> front = EdgeList[i];
- int w = front.first;
- int u = front.second.first;
- int v = front.second.second;
- if (!uf.find(u, v))
- {
- mst_cost += w;
- uf.unite(u, v);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment