Advertisement
xopsuei

trending topic

Dec 12th, 2012
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. //iterate until there are no elements
  2.     int u, v, c;
  3.     while(not pq.empty()){
  4.         pq.max(u,v,c);
  5.         sides[u] = not sides[u];
  6.         sides[v] = not sides[v];
  7.  
  8.        
  9.         int side = sides[u];
  10.         for(int i = neighbours_position[u]; i < neighbours_position[u + 1]; ++i){
  11.             //uptate cost or delete
  12.             int cost = get_cost(u, neighbours[i], neighbours, neighbours_position, sides);
  13.             if(cost > 0) pq.assign(u, neighbours[i], cost);
  14.             else pq.erase(u, neighbours[i]);
  15.         }
  16.  
  17.         side = sides[v];
  18.         for(int i = neighbours_position[v]; i < neighbours_position[v + 1]; ++i){
  19.             //uptate cost or delete
  20.             int cost = get_cost(u, neighbours[i], neighbours, neighbours_position, sides);
  21.             if(cost > 0) pq.assign(u, neighbours[i], cost);
  22.             else pq.erase(u, neighbours[i]);
  23.         }
  24.        
  25.         //uptate cost or delete
  26.         int cost = get_cost(u, v, neighbours, neighbours_position, sides);
  27.         if(cost > 0) pq.assign(u, v, cost);
  28.         else pq.erase(u, v);
  29.  
  30.  
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement