Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //iterate until there are no elements
- int u, v, c;
- while(not pq.empty()){
- pq.max(u,v,c);
- sides[u] = not sides[u];
- sides[v] = not sides[v];
- side = sides[u];
- for(int i = neighbours_position[u]; i < neighbours_position[u + 1]; ++i){
- //uptate cost or delete
- int cost = get_cost(u, i, neighbours, neighbours_position, sides);
- if(cost > 0) pq.assign(u, i, cost);
- else pq.erase(u, i);
- }
- side = sides[v];
- for(int i = neighbours_position[v]; i < neighbours_position[v + 1]; ++i){
- //uptate cost or delete
- int cost = get_cost(u, i, neighbours, neighbours_position, sides);
- if(cost > 0) pq.assign(u, i, cost);
- else pq.erase(u, i);
- }
- //uptate cost or delete
- int cost = get_cost(u, v, neighbours, neighbours_position, sides);
- if(cost > 0) pq.assign(u, v, cost);
- else pq.erase(u, v);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement