Advertisement
xopsuei

updated costs

Dec 12th, 2012
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 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.         side = sides[u];
  9.         for(int i = neighbours_position[u]; i < neighbours_position[u + 1]; ++i){
  10.             //uptate cost or delete
  11.             int cost = get_cost(u, i, neighbours, neighbours_position, sides);
  12.             if(cost > 0) pq.assign(u, i, cost);
  13.             else pq.erase(u, i);
  14.         }
  15.  
  16.         side = sides[v];
  17.         for(int i = neighbours_position[v]; i < neighbours_position[v + 1]; ++i){
  18.             //uptate cost or delete
  19.             int cost = get_cost(u, i, neighbours, neighbours_position, sides);
  20.             if(cost > 0) pq.assign(u, i, cost);
  21.             else pq.erase(u, i);
  22.         }
  23.  
  24.         //uptate cost or delete
  25.         int cost = get_cost(u, v, neighbours, neighbours_position, sides);
  26.         if(cost > 0) pq.assign(u, v, cost);
  27.         else pq.erase(u, v);
  28.  
  29.  
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement