Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef pair<int, int> ii;
- priority_queue<ii, vector<ii>, greater<ii>> pq;
- vector<bool> taken;
- taken.assign(V, false);
- taken[0] = true;
- mst_cost = 0;
- for (auto it = edge[0].begin(); it != edge[0].end; it++)
- pq.push(*it);
- while (!pq.empty())
- {
- ii front = pq.top(); pq.pop();
- u = front.second, w = front.first;
- if (!taken[u])
- {
- for (auto it = edge[u].begin(); it != edge[u].end(); it++)
- pq.push(*it);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment